From: Todd C. Miller Date: Mon, 11 Jan 2016 23:44:05 +0000 (-0700) Subject: Fix free() of invalid pointer introduced in the commit that stripped X-Git-Tag: SUDO_1_8_16^2~78 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14b454cc0df788ec2fc080af60994e49fa72a4ce;p=sudo Fix free() of invalid pointer introduced in the commit that stripped whitespace between a '!' and the name in a sudoOption. --- diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 1f547f557..c1e12b52e 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -1046,7 +1046,7 @@ static bool sudo_ldap_parse_options(LDAP *ld, LDAPMessage *entry) { struct berval **bv, **p; - char *cp, *var; + char *copy, *cp, *var; int op; bool rc = false; debug_decl(sudo_ldap_parse_options, SUDOERS_DEBUG_LDAP) @@ -1057,7 +1057,7 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMessage *entry) /* walk through options */ for (p = bv; *p != NULL; p++) { - if ((var = strdup((*p)->bv_val)) == NULL) { + if ((copy = var = strdup((*p)->bv_val)) == NULL) { sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); goto done; } @@ -1102,7 +1102,7 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMessage *entry) /* case var Boolean True */ set_default(var, NULL, true); } - free(var); + free(copy); } rc = true;