diff options
author | Karel Zak | 2012-01-26 14:17:28 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-26 14:17:28 +0100 |
commit | 258ca2b241e0c73660c7929186e82e7df53d7c6b (patch) | |
tree | 09eb7a8ff8cf44a80b5331804211338d96a014ba /libmount/src | |
parent | tests: call valgrind from libmount optstr test (diff) | |
download | kernel-qcow2-util-linux-258ca2b241e0c73660c7929186e82e7df53d7c6b.tar.gz kernel-qcow2-util-linux-258ca2b241e0c73660c7929186e82e7df53d7c6b.tar.xz kernel-qcow2-util-linux-258ca2b241e0c73660c7929186e82e7df53d7c6b.zip |
libmount: fix buffer overflow and leaks in tests
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/optstr.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c index 1a1c86c54..159ae62be 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; } |