OSDN Git Service

Don't let mktemp -q /path/to/file delete arbitrary files, and don't have
authorRob Landley <rob@landley.net>
Thu, 31 Dec 2015 02:54:19 +0000 (20:54 -0600)
committerRob Landley <rob@landley.net>
Thu, 31 Dec 2015 02:54:19 +0000 (20:54 -0600)
"mktemp -u > /dev/full" leave file around.

toys/lsb/mktemp.c

index f1f9d88..118dacc 100644 (file)
@@ -48,8 +48,10 @@ void mktemp_main(void)
     if (toys.optflags & FLAG_q) toys.exitval = 1;
     else perror_exit("Failed to create %s %s/%s",
                      d_flag ? "directory" : "file", TT.tmpdir, template);
-  } else xputs(template);
-  if (toys.optflags & FLAG_u) unlink(template);
+  } else {
+    if (toys.optflags & FLAG_u) unlink(template);
+    xputs(template);
+  }
 
   if (CFG_TOYBOX_FREE) free(template);
 }