diff options
| author | Simo Sorce <simo@redhat.com> | 2013-11-16 17:08:06 -0500 |
|---|---|---|
| committer | Simo Sorce <simo@redhat.com> | 2013-11-16 17:28:35 -0500 |
| commit | 5f6b2d295cc2542429f4e1b7144eb947681f64ca (patch) | |
| tree | 8edf59831d09e4c88fcf4a14d572aff9ebf1dc38 /proxy/src | |
| parent | d01b5199eefa3cf0974e5bf49295d00f389aa6eb (diff) | |
| download | gss-proxy-5f6b2d295cc2542429f4e1b7144eb947681f64ca.tar.gz gss-proxy-5f6b2d295cc2542429f4e1b7144eb947681f64ca.tar.xz gss-proxy-5f6b2d295cc2542429f4e1b7144eb947681f64ca.zip | |
config: Do not modify const strings
Take a copy here, the option string is const and strtok_r() is not a safe
function as it may change the string it manipulates.
Diffstat (limited to 'proxy/src')
| -rw-r--r-- | proxy/src/gp_config.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/proxy/src/gp_config.c b/proxy/src/gp_config.c index 8da291b..08d29fe 100644 --- a/proxy/src/gp_config.c +++ b/proxy/src/gp_config.c @@ -134,6 +134,7 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx) int num_sec; char *secname = NULL; const char *value; + char *vcopy; char *token; char *handle; int valnum; @@ -243,7 +244,12 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx) goto done; } - token = strtok_r(no_const(value), ", ", &handle); + vcopy = strdup(value); + if (!vcopy) { + ret = ENOMEM; + goto done; + } + token = strtok_r(vcopy, ", ", &handle); do { ret = strcmp(value, "krb5"); @@ -254,6 +260,7 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx) } else { GPERROR("Failed to read krb5 config for %s.\n", secname); + safefree(vcopy); return ret; } } else { @@ -263,6 +270,7 @@ static int load_services(struct gp_config *cfg, struct gp_ini_context *ctx) token = strtok_r(NULL, ", ", &handle); } while (token != NULL); + safefree(vcopy); if (cfg->svcs[n]->mechs == 0) { GPDEBUG("No mechs found for [%s], ignoring.\n", secname); |
