From: Karel Zak Date: Thu, 26 Jan 2012 13:17:28 +0000 (+0100) Subject: libmount: fix buffer overflow and leaks in tests X-Git-Tag: v2.21-rc2~97 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=258ca2b241e0c73660c7929186e82e7df53d7c6b;p=thirdparty%2Futil-linux.git libmount: fix buffer overflow and leaks in tests Signed-off-by: Karel Zak --- diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c index 1a1c86c540..159ae62be9 100644 --- a/libmount/src/optstr.c +++ b/libmount/src/optstr.c @@ -343,7 +343,7 @@ static int insert_value(char **str, char *pos, const char *substr, char **next) if (next) { /* set pointer to the next option */ - *next = pos + subsz + sep + 1; + *next = pos + subsz; if (**next == ',') (*next)++; } @@ -994,6 +994,7 @@ int test_append(struct libmnt_test *ts, int argc, char *argv[]) rc = mnt_optstr_append_option(&optstr, name, value); if (!rc) printf("result: >%s<\n", optstr); + free(optstr); return rc; } @@ -1014,6 +1015,7 @@ int test_prepend(struct libmnt_test *ts, int argc, char *argv[]) rc = mnt_optstr_prepend_option(&optstr, name, value); if (!rc) printf("result: >%s<\n", optstr); + free(optstr); return rc; } @@ -1161,6 +1163,7 @@ int test_remove(struct libmnt_test *ts, int argc, char *argv[]) rc = mnt_optstr_remove_option(&optstr, name); if (!rc) printf("result: >%s<\n", optstr); + free(optstr); return rc; }