[File] brief impossible bug: magic_file(MAGIC_COMPRESS) for test.lz -> vfork() + waitpid(pid) + waitpid(0) = sleep forever

raf file at raf.org
Tue Apr 7 03:20:32 EDT 2026


The patch was scrubbed by mailman. Here it is.
Note that initializing pid is optional.

cheers,
raf

diff -durp file-5.46.orig/src/compress.c file-5.46/src/compress.c
--- file-5.46.orig/src/compress.c	2026-04-06 11:08:45.773515833 +1000
+++ file-5.46/src/compress.c	2026-04-06 11:06:41.667496056 +1000
@@ -1126,7 +1126,7 @@ uncompressbuf(int fd, size_t bytes_max,
 {
 	int fdp[3][2];
 	int status, rv, w;
-	pid_t pid;
+	pid_t pid = -1;
 	pid_t writepid = -1;
 	size_t i;
 	ssize_t r, re;
@@ -1190,9 +1190,9 @@ uncompressbuf(int fd, size_t bytes_max,
 
 	posix_spawn_file_actions_destroy(&fa);
 
-	if (status == -1) {
+	if (status != 0) {
 		return makeerror(newch, n, "Cannot posix_spawn `%s', %s",
-		    compr[method].argv[0], strerror(errno));
+		    compr[method].argv[0], strerror(status));
 	}
 #else
 	/* For processes with large mapped virtual sizes, vfork


More information about the File mailing list