Skip to content

Commit

Permalink
Fix ressource leak in client/config.c get_config_entry
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
  • Loading branch information
t-woerner authored and tiran committed Oct 23, 2018
1 parent 5c0885d commit 389c17c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,18 @@ get_config_entry(char * in_data, const char *section, const char *key)
line++;
p = strchr(line, ']');
if (p) {
tmp = strndup(line, p - line);
if (in_section) {
/* We exited the matching section without a match */
free(data);
return NULL;
}
tmp = strndup(line, p - line);
if (strcmp(section, tmp) == 0) {
free(tmp);
in_section = 1;
continue;
}
free(tmp);
}
} /* [ */

Expand Down

0 comments on commit 389c17c

Please sign in to comment.