fold in patch from Jim Paris for use of mkstemps to improve security
authorBdale Garbee <bdale@gag.com>
Wed, 11 Jan 2012 18:22:37 +0000 (11:22 -0700)
committerBdale Garbee <bdale@gag.com>
Wed, 11 Jan 2012 18:22:37 +0000 (11:22 -0700)
debian/changelog
debian/patches/as31-mkstemps.patch [new file with mode: 0644]
debian/patches/series

index ac23c36fc2efbca9c201d40b692e0f93f5072403..d523b9ee651c2d5130a5029f679f45dc04bd8851 100644 (file)
@@ -2,6 +2,7 @@ as31 (2.3.1-5) unstable; urgency=low
 
   * force regeneration of stale upstream parser.c to resolve "location
     counter overlaps" errors on 64-bit machines, closes: #655487
+  * patch from Jim Paris to use mkstemps, closes: #655496
 
  -- Bdale Garbee <bdale@gag.com>  Wed, 11 Jan 2012 11:15:32 -0700
 
diff --git a/debian/patches/as31-mkstemps.patch b/debian/patches/as31-mkstemps.patch
new file mode 100644 (file)
index 0000000..688cb59
--- /dev/null
@@ -0,0 +1,34 @@
+--- as31-2.3.1/as31/run.c      2005-09-05 12:32:42.000000000 -0400
++++ as31-2.3.1-fixed/as31/run.c        2012-01-11 12:30:19.000000000 -0500
+@@ -39,8 +39,8 @@
+       char *incLineBuffer=NULL;
+       int incSizeBuf=0;
+       FILE* includeFile=NULL;
++      int fd;
+-      uid_t uid; 
+       /* first, figure out all the file names */
+       dashl = lst;
+@@ -95,11 +95,18 @@
+               }
+       }
+       
+-      uid = geteuid();
+-      sprintf(tmpName,"/tmp/as31-%i-%ld.asm",uid,random());
+-      fin = fopen(tmpName, "w");
++      sprintf(tmpName,"/tmp/as31-XXXXXX.asm");
++      fd = mkstemps(tmpName, 4);
++      if (fd == -1) {
++              mesg_f("Cannot create temp file\n");
++              if (outfile) free(outfile);
++              if (lstfile) free(lstfile);
++              return -1;
++      }
++      fin = fdopen(fd, "w");
+       if (fin == NULL) {
+               mesg_f("Cannot open temp file: %s\n",tmpName);
++              close(fd);
+               if (outfile) free(outfile);
+               if (lstfile) free(lstfile);
+               return -1;
index 70e71975529fb98c497ad095e06f8c38c9d5f57c..a3a6c63b215a3fc7e1b45535e1df39a6096a93af 100644 (file)
@@ -1,2 +1,3 @@
 elide_errant_text
 regenerate_parser.c
+as31-mkstemps.patch