From 3a283d40b50b4854066d30ef19c3af7b5b3b4866 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 20 Nov 2026 16:06:19 +0100 Subject: [PATCH] tmpfiles: free the glob result of r, R, w, z, and Z entries Same leak as for e entries: the path list from glob() was never freed. With the address sanitizer LeakSanitizer makes tmpfiles exit with an error: tmpfiles --remove r.conf Free the list in glob_do() and after the loops for w and z/Z. Signed-off-by: Joachim Wiberg --- src/tmpfiles.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tmpfiles.c b/src/tmpfiles.c index 20cafb96..5efdf7f1 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -108,6 +108,7 @@ static int glob_do(const char *path, int (*cb)(const char *)) for (size_t i = 0; i < gl.gl_pathc; i++) rc += cb(gl.gl_pathv[i]); + globfree(&gl); return rc; } @@ -1016,6 +1017,7 @@ static void tmpfiles(char *line) rc = fclose(fp); } } + globfree(&gl); break; case 'X': case 'x': @@ -1032,6 +1034,7 @@ static void tmpfiles(char *line) for (size_t i = 0; i < gl.gl_pathc; i++) systemf("restorecon %s %s", opts, gl.gl_pathv[i]); + globfree(&gl); break; default: errx(1, "Unsupported tmpfiles command '%s'", type);