[File] Fix regular-file description spacing
Steve Grubb
sgrubb at redhat.com
Sun Aug 16 14:02:09 EDT 2026
The filesystem attribute refactor (7fdb7bf9) kept "did" as a pointer so the COMMA macro could change it. The final regular-file check then tested the pointer instead of the number of attributes printed, so it added a leading space to every non-empty regular-file description. Here's a reproducer for the master branch:
printf 'hello\n' > /tmp/fsmagic-repro
$ ./src/file -b -m ./magic/magic /tmp/fsmagic-repro
, ASCII text
Dereferencing the pointer to inspect the value fixes the problem. The output now looks like this with the patch applied:
$ ./src/file -b -m ./magic/magic /tmp/fsmagic-repro
ASCII text
diff --git a/src/fsmagic.c b/src/fsmagic.c
index 592edc97..bd769d82 100644
--- a/src/fsmagic.c
+++ b/src/fsmagic.c
@@ -485,7 +485,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
/*NOTREACHED*/
}
- if (!silent && !mime && did && ret == 0) {
+ if (!silent && !mime && *did && ret == 0) {
if (file_printf(ms, " ") == -1)
return -1;
}
More information about the File
mailing list