Fix ressource leak in client/config.c get_config_entry

The leak happens due to using strndup to create a temporary string without
freeing it afterwards.

See: https://pagure.io/freeipa/issue/7738
Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Thomas Woerner
2018-10-22 13:57:11 +02:00
committed by Christian Heimes
parent 5c0885d266
commit 389c17c5c6

View File

@@ -123,17 +123,18 @@ get_config_entry(char * in_data, const char *section, const char *key)
line++; line++;
p = strchr(line, ']'); p = strchr(line, ']');
if (p) { if (p) {
tmp = strndup(line, p - line);
if (in_section) { if (in_section) {
/* We exited the matching section without a match */ /* We exited the matching section without a match */
free(data); free(data);
return NULL; return NULL;
} }
tmp = strndup(line, p - line);
if (strcmp(section, tmp) == 0) { if (strcmp(section, tmp) == 0) {
free(tmp); free(tmp);
in_section = 1; in_section = 1;
continue; continue;
} }
free(tmp);
} }
} /* [ */ } /* [ */