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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:02:34 +01:00
1 parent 674cf8a2ed
commit 3a283d40b5
1 file changed
+3
+3
View File
@@ -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);