From: Samanta Navarro Date: Sun, 8 Nov 2020 11:44:55 +0000 (+0000) Subject: libblkid: fix memory leak in config parser X-Git-Tag: v2.36.1~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f3de85b5e16be8b59cd451818585f97650829b3;p=thirdparty%2Futil-linux.git libblkid: fix memory leak in config parser Multiple occurrences of CACHE_FILE lead to memory leaks. Also if last occurrence of CACHE_FILE is empty then cache file is not set to NULL again. An example /etc/blkid.conf could be: CACHE_FILE=/tmp/cache1 CACHE_FILE=/tmp/cache2 CACHE_FILE= I would expect that CACHE_FILE is empty but actually it is still /tmp/cache2. Signed-off-by: Samanta Navarro --- diff --git a/libblkid/src/config.c b/libblkid/src/config.c index 52f159d870..f229b3e632 100644 --- a/libblkid/src/config.c +++ b/libblkid/src/config.c @@ -95,8 +95,11 @@ static int parse_next(FILE *fd, struct blkid_config *conf) conf->uevent = FALSE; } else if (!strncmp(s, "CACHE_FILE=", 11)) { s += 11; + free(conf->cachefile); if (*s) conf->cachefile = strdup(s); + else + conf->cachefile = NULL; } else if (!strncmp(s, "EVALUATE=", 9)) { s += 9; if (*s && parse_evaluate(conf, s) == -1)