From: Wichert Akkerman Date: Sun, 22 Apr 2001 14:43:46 +0000 (+0000) Subject: do not read a .list or statoverride file if they are empty X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eff5e017f54b8a35a372e02a4eef1b6d0af4bf1a;p=dpkg do not read a .list or statoverride file if they are empty --- diff --git a/ChangeLog b/ChangeLog index 4e853ff3..80a488d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 22 16:42:22 CEST 2001 Wichert Akkerman + + * main/filesdb.c: don't read a statoverride or .list file if they + are 0 bytes + Sun Apr 22 02:46:06 CDT 2001 Adam Heath * dpkg-deb/build.c, dpkg-deb/extract.c, dpkg-deb/main.c, lib/mlib.c(*), diff --git a/main/filesdb.c b/main/filesdb.c index 6b4927c6..2e40aba3 100644 --- a/main/filesdb.c +++ b/main/filesdb.c @@ -139,30 +139,33 @@ void ensure_packagefiles_available(struct pkginfo *pkg) { if(fstat(fd, &stat_buf)) ohshite("unable to stat files list file for package `%.250s'",pkg->name); - loaded_list = nfmalloc(stat_buf.st_size); - loaded_list_end = loaded_list + stat_buf.st_size; - fd_buf_copy(fd, loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name); - - lendp= &pkg->clientdata->files; - thisline = loaded_list; - while (thisline < loaded_list_end) { - if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline))) - ohshit("files list file for package `%.250s' is missing final newline",pkg->name); - /* where to start next time around */ - nextline = ptr + 1; - /* strip trailing "/" */ - if (ptr > thisline && ptr[-1] == '/') ptr--; - /* add the file to the list */ - if (ptr == thisline) - ohshit(_("files list file for package `%.250s' contains empty filename"),pkg->name); - *ptr = 0; - newent= nfmalloc(sizeof(struct fileinlist)); - newent->namenode= findnamenode(thisline, fnn_nocopy); - newent->next= 0; - *lendp= newent; - lendp= &newent->next; - thisline = nextline; + if (stat_buf.st_size) { + loaded_list = nfmalloc(stat_buf.st_size); + loaded_list_end = loaded_list + stat_buf.st_size; + + fd_buf_copy(fd, loaded_list, stat_buf.st_size, _("files list for package `%.250s'"), pkg->name); + + lendp= &pkg->clientdata->files; + thisline = loaded_list; + while (thisline < loaded_list_end) { + if (!(ptr = memchr(thisline, '\n', loaded_list_end - thisline))) + ohshit("files list file for package `%.250s' is missing final newline",pkg->name); + /* where to start next time around */ + nextline = ptr + 1; + /* strip trailing "/" */ + if (ptr > thisline && ptr[-1] == '/') ptr--; + /* add the file to the list */ + if (ptr == thisline) + ohshit(_("files list file for package `%.250s' contains empty filename"),pkg->name); + *ptr = 0; + newent= nfmalloc(sizeof(struct fileinlist)); + newent->namenode= findnamenode(thisline, fnn_nocopy); + newent->next= 0; + *lendp= newent; + lendp= &newent->next; + thisline = nextline; + } } pop_cleanup(ehflag_normaltidy); /* fd= open() */ if (close(fd)) @@ -336,6 +339,12 @@ void ensure_statoverrides(void) { if (statoverridefile) fclose(statoverridefile); statoverridefile= file; + /* If the statoverride list is empty we don't need to bother reading it. */ + if (!stab2.st_size) { + onerr_abort--; + return; + } + loaded_list = nfmalloc(stab2.st_size); loaded_list_end = loaded_list + stab2.st_size;