summaryrefslogtreecommitdiff
path: root/libcli/auth
diff options
context:
space:
mode:
Diffstat (limited to 'libcli/auth')
-rw-r--r--libcli/auth/spnego.h2
-rw-r--r--libcli/auth/spnego_parse.c27
-rw-r--r--libcli/auth/spnego_proto.h2
3 files changed, 18 insertions, 13 deletions
diff --git a/libcli/auth/spnego.h b/libcli/auth/spnego.h
index 9a93f2ed52..539b90336f 100644
--- a/libcli/auth/spnego.h
+++ b/libcli/auth/spnego.h
@@ -49,7 +49,7 @@ enum spnego_negResult {
};
struct spnego_negTokenInit {
- const char **mechTypes;
+ const char * const *mechTypes;
DATA_BLOB reqFlags;
uint8_t reqFlagsPadding;
DATA_BLOB mechToken;
diff --git a/libcli/auth/spnego_parse.c b/libcli/auth/spnego_parse.c
index 2c73613e3b..b1ca07d637 100644
--- a/libcli/auth/spnego_parse.c
+++ b/libcli/auth/spnego_parse.c
@@ -42,12 +42,14 @@ static bool read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
switch (context) {
/* Read mechTypes */
- case ASN1_CONTEXT(0):
+ case ASN1_CONTEXT(0): {
+ const char **mechTypes;
+
asn1_start_tag(asn1, ASN1_CONTEXT(0));
asn1_start_tag(asn1, ASN1_SEQUENCE(0));
- token->mechTypes = talloc(mem_ctx, const char *);
- if (token->mechTypes == NULL) {
+ mechTypes = talloc(mem_ctx, const char *);
+ if (mechTypes == NULL) {
asn1->has_error = true;
return false;
}
@@ -56,22 +58,25 @@ static bool read_negTokenInit(struct asn1_data *asn1, TALLOC_CTX *mem_ctx,
char *oid;
const char **p;
p = talloc_realloc(mem_ctx,
- token->mechTypes,
+ mechTypes,
const char *, i+2);
if (p == NULL) {
- TALLOC_FREE(token->mechTypes);
+ talloc_free(mechTypes);
asn1->has_error = true;
return false;
}
- token->mechTypes = p;
- asn1_read_OID(asn1, token->mechTypes, &oid);
- token->mechTypes[i] = oid;
+ mechTypes = p;
+
+ asn1_read_OID(asn1, mechTypes, &oid);
+ mechTypes[i] = oid;
}
- token->mechTypes[i] = NULL;
+ mechTypes[i] = NULL;
+ token->mechTypes = mechTypes;
asn1_end_tag(asn1);
asn1_end_tag(asn1);
break;
+ }
/* Read reqFlags */
case ASN1_CONTEXT(1):
asn1_start_tag(asn1, ASN1_CONTEXT(1));
@@ -366,7 +371,7 @@ bool spnego_free_data(struct spnego_data *spnego)
switch(spnego->type) {
case SPNEGO_NEG_TOKEN_INIT:
if (spnego->negTokenInit.mechTypes) {
- talloc_free(spnego->negTokenInit.mechTypes);
+ talloc_free(discard_const(spnego->negTokenInit.mechTypes));
}
data_blob_free(&spnego->negTokenInit.reqFlags);
data_blob_free(&spnego->negTokenInit.mechToken);
@@ -390,7 +395,7 @@ out:
}
bool spnego_write_mech_types(TALLOC_CTX *mem_ctx,
- const char **mech_types,
+ const char * const *mech_types,
DATA_BLOB *blob)
{
struct asn1_data *asn1 = asn1_init(mem_ctx);
diff --git a/libcli/auth/spnego_proto.h b/libcli/auth/spnego_proto.h
index 5fd5e59c65..c0fa93468d 100644
--- a/libcli/auth/spnego_proto.h
+++ b/libcli/auth/spnego_proto.h
@@ -24,5 +24,5 @@ ssize_t spnego_read_data(TALLOC_CTX *mem_ctx, DATA_BLOB data, struct spnego_data
ssize_t spnego_write_data(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct spnego_data *spnego);
bool spnego_free_data(struct spnego_data *spnego);
bool spnego_write_mech_types(TALLOC_CTX *mem_ctx,
- const char **mech_types,
+ const char * const *mech_types,
DATA_BLOB *blob);