From d31b2503d41a80e356f3bf931aec94f021961a72 Mon Sep 17 00:00:00 2001 From: Wichert Akkerman Date: Wed, 13 Oct 1999 18:47:08 +0000 Subject: [PATCH] Change oldfile-check in process_archive to prevent memory corruption --- ChangeLog | 5 +++++ main/filesdb.h | 1 - main/processarc.c | 11 ++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60349b5b..8c4d919d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 13 20:41:16 CEST 1999 Wichert Akkerman + + * Update oldfile-check in process_archive so we don't experience + memory corruption + Wed Oct 13 17:51:17 CEST 1999 Wichert Akkerman * Merge patches from Ben Collins : diff --git a/main/filesdb.h b/main/filesdb.h index 83c6533c..7a3ecf29 100644 --- a/main/filesdb.h +++ b/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 { diff --git a/main/processarc.c b/main/processarc.c index d155d8d9..828f7253 100644 --- a/main/processarc.c +++ b/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); -- 2.39.5