From: Zbigniew Jędrzejewski-Szmek Date: Fri, 22 Feb 2019 12:23:57 +0000 (+0100) Subject: test-mountpoint-util: unpoison string allocated by sscanf %ms X-Git-Tag: v242-rc1~250^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9003da29631b5348a4578d605e150321adbd3461;p=thirdparty%2Fsystemd.git test-mountpoint-util: unpoison string allocated by sscanf %ms --- diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 8e45c0b1a7a..be764295065 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -36,7 +36,7 @@ static void test_mount_propagation_flags(const char *name, int ret, unsigned lon static void test_mnt_id(void) { _cleanup_fclose_ FILE *f = NULL; - Hashmap *h; + _cleanup_hashmap_free_free_ Hashmap *h = NULL; Iterator i; char *p; void *k; @@ -57,7 +57,14 @@ static void test_mnt_id(void) { assert_se(r > 0); assert_se(sscanf(line, "%i %*s %*s %*s %ms", &mnt_id, &path) == 2); - +#if HAS_FEATURE_MEMORY_SANITIZER + /* We don't know the length of the string, so we need to unpoison it one char at a time */ + for (const char *c = path; ;c++) { + msan_unpoison(c, 1); + if (!*c) + break; + } +#endif log_debug("mountinfo: %s → %i", path, mnt_id); assert_se(hashmap_put(h, INT_TO_PTR(mnt_id), path) >= 0); @@ -84,8 +91,6 @@ static void test_mnt_id(void) { log_debug("the other path for mnt id %i is %s\n", mnt_id2, t); assert_se(path_equal(p, t)); } - - hashmap_free_free(h); } static void test_path_is_mount_point(void) {