test-mountpoint-util: unpoison string allocated by sscanf %ms

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-02-25 10:07:18 +01:00
parent c322f379e6
commit 9003da2963
+9 -4
View File
@@ -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) {