Procházet zdrojové kódy

Change oldfile-check in process_archive to prevent memory corruption

Wichert Akkerman před 27 roky
rodič
revize
d31b2503d4
3 změnil soubory, kde provedl 9 přidání a 8 odebrání
  1. 5 0
      ChangeLog
  2. 0 1
      main/filesdb.h
  3. 4 7
      main/processarc.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Wed Oct 13 20:41:16 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Update oldfile-check in process_archive so we don't experience
+    memory corruption
+
 Wed Oct 13 17:51:17 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
 
   * Merge patches from Ben Collins <bcollins@debian.org>:

+ 0 - 1
main/filesdb.h

@@ -62,7 +62,6 @@ struct filenamenode {
     fnnf_no_atomic_overwrite= 000020, /* >=1 instance is a dir, cannot rename over */
   } flags; /* Set to zero when a new node is created. */
   const char *oldhash; /* valid iff this namenode is in the newconffiles list */
-  struct stat *stat;
 };
  
 struct fileinlist {

+ 4 - 7
main/processarc.c

@@ -609,13 +609,10 @@ void process_archive(const char *filename) {
 	  upgrade/downgrade", fnamevb.buf);
       if (!lstat(fnamevb.buf, &oldfs) && !S_ISDIR(oldfs.st_mode)) {
 	for (cfile = newfileslist; cfile; cfile = cfile->next) {
-	  if(!cfile->namenode->stat) {
-	    newfs = nfmalloc(sizeof(struct stat));
-	    if (lstat(cfile->namenode->name, newfs)) continue;
-	    cfile->namenode->stat = newfs;
-	  } else newfs = cfile->namenode->stat;
-	  if (!S_ISDIR(newfs->st_mode) && oldfs.st_dev == newfs->st_dev &&
-	      oldfs.st_ino == newfs->st_ino) {
+          if (lstat(cfile->namenode->name, &newfs) || S_ISDIR(newfs.st_mode))
+            continue;
+          if (oldfs.st_dev == newfs.st_dev &&
+              oldfs.st_ino == newfs.st_ino) {
 	    donotrm = 1;
 	    debug(dbg_eachfile, "process_archive: not removing %s, since it matches %s",
 		fnamevb.buf, cfile->namenode->name);