Const-correct X509V3_CONF_METHOD.

This is needed to fix all the config APIs to take const char *. I've
split it out as it's the only incompatible half of the change.

Update-Note: External definitions of X509V3_CONF_METHOD will need fix
the types of their functions. There should not be any of these (probably
hide this struct), but if there are, this aligns with upstream OpenSSL.

Change-Id: I6e760cfbca5d3f408215b8f3744acd1fd7f31391
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42727
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
chromium-5359
David Benjamin 5 years ago committed by CQ bot account: commit-bot@chromium.org
parent 6247347edd
commit 6d70353ca8
  1. 10
      crypto/x509v3/v3_conf.c
  2. 4
      include/openssl/x509v3.h

@ -428,13 +428,17 @@ void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section)
ctx->db_meth->free_section(ctx->db, section); ctx->db_meth->free_section(ctx->db, section);
} }
static char *nconf_get_string(void *db, char *section, char *value) static char *nconf_get_string(void *db, const char *section, const char *value)
{ {
/* TODO(fork): this should return a const value. */ /* TODO(fork): This returns a non-const pointer because |X509V3_CONF_METHOD|
* allows |get_string| to return caller-owned pointers, provided they're
* freed by |free_string|. |nconf_method| leaves |free_string| NULL, and
* there are no other implementations of |X509V3_CONF_METHOD|, so this can
* be simplified if we make it private. */
return (char *)NCONF_get_string(db, section, value); return (char *)NCONF_get_string(db, section, value);
} }
static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, char *section) static STACK_OF(CONF_VALUE) *nconf_get_section(void *db, const char *section)
{ {
return NCONF_get_section(db, section); return NCONF_get_section(db, section);
} }

@ -126,8 +126,8 @@ void *usr_data; /* Any extension specific data */
}; };
typedef struct X509V3_CONF_METHOD_st { typedef struct X509V3_CONF_METHOD_st {
char * (*get_string)(void *db, char *section, char *value); char * (*get_string)(void *db, const char *section, const char *value);
STACK_OF(CONF_VALUE) * (*get_section)(void *db, char *section); STACK_OF(CONF_VALUE) * (*get_section)(void *db, const char *section);
void (*free_string)(void *db, char * string); void (*free_string)(void *db, char * string);
void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section); void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section);
} X509V3_CONF_METHOD; } X509V3_CONF_METHOD;

Loading…
Cancel
Save