From 258ca2b241e0c73660c7929186e82e7df53d7c6b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 26 Jan 2012 14:17:28 +0100 Subject: [PATCH] libmount: fix buffer overflow and leaks in tests Signed-off-by: Karel Zak --- libmount/src/optstr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; } -- 2.47.3