Package: debianutils
Version: 3.1

If I run tempfile without arguments, it aborts with

*** glibc detected *** ./tempfile: double free or corruption (fasttop): 
0x0000000000801010 ***

and a long backtrace.

This is caused by the free of name and filename, after filename was set to
the same address as name if no suffix is given (see line 120-129).

Patch is attached.
--- tempfile.c	2009-05-02 09:18:48.000000000 +0200
+++ tempfile.c.orig	2009-05-02 09:17:19.000000000 +0200
@@ -131,8 +131,7 @@
       if ((fd = open(filename, O_RDWR | O_CREAT | O_EXCL, mode)) < 0) {
 	if (errno == EEXIST) {
 	  free(name);
-          if (name != filename)
-	    free(filename);
+	  free(filename);
 	  continue;
 	}
 	syserror("open");
@@ -145,7 +144,6 @@
     syserror("close");
   puts(filename);
   free(filename);
-  if (name != filename)
-    free(name);
+  free(name);
   exit(0);
 }

Attachment: signature.asc
Description: Digital signature

Reply via email to