Kaynağa Gözat

Merge branch 'master' of ssh://git.debian.org/git/dpkg/dpkg

Christian Perrier 18 yıl önce
ebeveyn
işleme
a5e1002afe
13 değiştirilmiş dosya ile 139 ekleme ve 69 silme
  1. 42 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 1 1
      dpkg-deb/extract.c
  4. 1 0
      lib/Makefile.am
  5. 59 0
      lib/cleanup.c
  6. 15 3
      lib/dbmodify.c
  7. 3 0
      lib/dpkg-db.h
  8. 8 0
      lib/dpkg.h
  9. 2 0
      lib/tarfn.c
  10. 6 0
      lib/utils.c
  11. 0 32
      src/help.c
  12. 0 6
      src/main.h
  13. 0 27
      src/query.c

+ 42 - 0
ChangeLog

@@ -1,3 +1,45 @@
+2008-03-20  Guillem Jover  <guillem@debian.org>
+
+	* dpkg-deb/extract.c (safe_fflush): Change return type from int to
+	void.
+
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* lib/dpkg.h (cisspace): New prototype.
+	* lib/utils.c (cisspace): New function definition.
+
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* src/main.h (pkgadminfile): Move prototype to ...
+	* lib/dpkg-db.h: ... here.
+	* src/help.c (pkgadminfile): Move function definition to ...
+	* lib/dbmodify.c: ... here.
+	* src/query.c (pkgadminfile): Remove duplicated functions.
+
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>,
+            Guillem Jover  <guillem@debian.org>
+
+	* src/query.c (cu_closepipe, cu_closefile, cu_closefd): Remove
+	duplicated functions.
+	* src/help.c (cu_closepipe, cu_closefile, cu_closedir)
+	(cu_closefd): Move function definitions to ...
+	* lib/cleanup.c: ... here. New file.
+	* src/main.h (cu_closefile, cu_closepipe, cu_closedir)
+	(cu_closefd): Move prototypes to ...
+	* lib/dpkg.h: ... here.
+	* lib/Makefile.am (libdpkg_a_SOURCES): Add 'cleanup.c'.
+
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* lib/dpkg-db.h (modstatdb_checkpoint): New prototype.
+	* lib/dbmodify.c (checkpoint):  Remove static keyword. Rename to ...
+	(modstatdb_checkpoint): ... this. Fix all callers.
+
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* lib/tarfn.c (TarExtractor): Initialize h.LinkName and h.Name to
+	NULL.
+
 2008-03-16  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/Dpkg/Shlibs/Objdump.pm: Add "objid" property to

+ 2 - 0
debian/changelog

@@ -27,6 +27,8 @@ dpkg (1.14.17) UNRELEASED; urgency=low
     Thanks to Ian Jackson.
   * Allow compilation with --disable-nls on systems without libintl.h where
     a non glibc claims to be glibc. Closes: #465420
+  * Fix crash when a .deb file becomes unreadable while dpkg is starting.
+    Thanks to Ian Jackson. Closes: #386210
 
   [ Raphael Hertzog ]
   * Add a warning displayed by dpkg-genchanges if the current version is

+ 1 - 1
dpkg-deb/extract.c

@@ -85,7 +85,7 @@ parseheaderlength(const char *inh, size_t len,
   return (size_t)r;
 }
 
-static int
+static void
 safe_fflush(FILE *f)
 {
 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ > 0)

+ 1 - 0
lib/Makefile.am

@@ -15,6 +15,7 @@ libdpkg_a_SOURCES = \
 	dpkg-def.h \
 	dpkg.h \
 	dpkg-db.h \
+	cleanup.c \
 	compat.c \
 	compression.c \
 	database.c \

+ 59 - 0
lib/cleanup.c

@@ -0,0 +1,59 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * cleanup.c - cleanup functions, used when we need to unwind
+ *
+ * Copyright (C) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with dpkg; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <dpkg.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <dirent.h>
+
+void
+cu_closepipe(int argc, void **argv)
+{
+	int *p1 = (int *)argv[0];
+
+	close(p1[0]);
+	close(p1[1]);
+}
+
+void
+cu_closefile(int argc, void **argv)
+{
+	FILE *f = (FILE *)(argv[0]);
+
+	fclose(f);
+}
+
+void
+cu_closedir(int argc, void **argv)
+{
+	DIR *d = (DIR *)(argv[0]);
+
+	closedir(d);
+}
+
+void
+cu_closefd(int argc, void **argv)
+{
+	int ip = *(int *)argv[0];
+
+	close(ip);
+}
+

+ 15 - 3
lib/dbmodify.c

@@ -195,7 +195,7 @@ enum modstatdb_rw modstatdb_init(const char *adir, enum modstatdb_rw readwritere
   return cstatus;
 }
 
-static void checkpoint(void) {
+void modstatdb_checkpoint(void) {
   int i;
 
   assert(cstatus >= msdbrw_write);
@@ -214,7 +214,7 @@ void modstatdb_shutdown(void) {
   const struct fni *fnip;
   switch (cstatus) {
   case msdbrw_write:
-    checkpoint();
+    modstatdb_checkpoint();
     writedb(availablefile,1,0);
     /* tidy up a bit, but don't worry too much about failure */
     fclose(importanttmp);
@@ -279,7 +279,7 @@ void modstatdb_note(struct pkginfo *pkg) {
   nextupdate++;  
 
   if (nextupdate > MAXUPDATES) {
-    checkpoint();
+    modstatdb_checkpoint();
     nextupdate= 0;
   }
 
@@ -288,6 +288,18 @@ void modstatdb_note(struct pkginfo *pkg) {
   onerr_abort--;
 }
 
+const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
+  static struct varbuf vb;
+  varbufreset(&vb);
+  varbufaddstr(&vb,admindir);
+  varbufaddstr(&vb,"/" INFODIR);
+  varbufaddstr(&vb,pkg->name);
+  varbufaddc(&vb,'.');
+  varbufaddstr(&vb,whichfile);
+  varbufaddc(&vb,0);
+  return vb.buf;
+}
+
 const char *log_file= NULL;
 
 void log_message(const char *fmt, ...) {

+ 3 - 0
lib/dpkg-db.h

@@ -170,10 +170,13 @@ extern struct pipef *status_pipes;
 
 enum modstatdb_rw modstatdb_init(const char *admindir, enum modstatdb_rw reqrwflags);
 void modstatdb_note(struct pkginfo *pkg);
+void modstatdb_checkpoint(void);
 void modstatdb_shutdown(void);
 
 extern char *statusfile, *availablefile; /* initialised by modstatdb_init */
 
+const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile);
+
 extern const char *log_file;
 void log_message(const char *fmt, ...) PRINTFFORMAT(1, 2);
 

+ 8 - 0
lib/dpkg.h

@@ -207,6 +207,13 @@ void badusage(const char *fmt, ...) NONRETURNING PRINTFFORMAT(1, 2);
 void werr(const char *what) NONRETURNING;
 void warningf(const char *fmt, ...) PRINTFFORMAT(1, 2);
 
+/*** cleanup.c ***/
+
+void cu_closefile(int argc, void **argv);
+void cu_closepipe(int argc, void **argv);
+void cu_closedir(int argc, void **argv);
+void cu_closefd(int argc, void **argv);
+
 /*** from mlib.c ***/
 
 void setcloexec(int fd, const char* fn);
@@ -355,6 +362,7 @@ extern volatile int onerr_abort;
 
 int cisdigit(int c);
 int cisalpha(int c);
+int cisspace(int c);
 
 int fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn);
 int fgets_must(char *buf, size_t bufsz, FILE *f, const char *fn);

+ 2 - 0
lib/tarfn.c

@@ -140,6 +140,8 @@ TarExtractor(
 	symListBottom = symListPointer = symListTop = m_malloc(sizeof(symlinkList));
 	symListTop->next = NULL;
 
+	h.Name = NULL;
+	h.LinkName = NULL;
 	h.UserData = userData;
 
 	while ( (status = functions->Read(userData, buffer, 512)) == 512 ) {

+ 6 - 0
lib/utils.c

@@ -34,6 +34,12 @@ int cisalpha(int c) {
 	return ((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'));
 }
 
+int
+cisspace(int c)
+{
+	return (c == '\n' || c == '\t' || c == ' ');
+}
+
 int
 fgets_checked(char *buf, size_t bufsz, FILE *f, const char *fn)
 {

+ 0 - 32
src/help.c

@@ -121,26 +121,6 @@ void ensure_package_clientdata(struct pkginfo *pkg) {
   pkg->clientdata->files = NULL;
 }
 
-void cu_closepipe(int argc, void **argv) {
-  int *p1= (int*)argv[0];
-  close(p1[0]); close(p1[1]);
-}
-
-void cu_closefile(int argc, void **argv) {
-  FILE *f= (FILE*)(argv[0]);
-  fclose(f);
-}
-
-void cu_closedir(int argc, void **argv) {
-  DIR *d= (DIR*)(argv[0]);
-  closedir(d);
-}
-
-void cu_closefd(int argc, void **argv) {
-  int ip= *(int*)argv[0];
-  close(ip);
-}
-
 int ignore_depends(struct pkginfo *pkg) {
   struct packageinlist *id;
   for (id= ignoredependss; id; id= id->next)
@@ -164,18 +144,6 @@ int force_conflicts(struct deppossi *possi) {
   return fc_conflicts;
 }
 
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
-  static struct varbuf vb;
-  varbufreset(&vb);
-  varbufaddstr(&vb,admindir);
-  varbufaddstr(&vb,"/" INFODIR);
-  varbufaddstr(&vb,pkg->name);
-  varbufaddc(&vb,'.');
-  varbufaddstr(&vb,whichfile);
-  varbufaddc(&vb,0);
-  return vb.buf;
-}
-
 static const char* preexecscript(const char *path, char *const *argv) {
   /* returns the path to the script inside the chroot
    * none of the stuff here will work if admindir isn't inside instdir

+ 0 - 6
src/main.h

@@ -173,11 +173,6 @@ int skip_due_to_hold(struct pkginfo *pkg);
 
 /* from help.c */
 
-void cu_closefile(int argc, void **argv);
-void cu_closepipe(int argc, void **argv);
-void cu_closedir(int argc, void **argv);
-void cu_closefd(int argc, void **argv);
-
 struct stat;
 
 int ignore_depends(struct pkginfo *pkg);
@@ -187,7 +182,6 @@ int force_conff_new(struct deppossi *possi);
 int force_conff_miss(struct deppossi *possi);
 int force_conflicts(struct deppossi *possi);
 void ensure_package_clientdata(struct pkginfo *pkg);
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile);
 void oldconffsetflags(const struct conffile *searchconff);
 void ensure_pathname_nonexisting(const char *pathname);
 int chmodsafe_unlink(const char *pathname, const char **failed);

+ 0 - 27
src/query.c

@@ -54,33 +54,6 @@ void ensure_package_clientdata(struct pkginfo *pkg) {
   pkg->clientdata->files= 0;
 }
 
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
-  static struct varbuf vb;
-  varbufreset(&vb);
-  varbufaddstr(&vb,admindir);
-  varbufaddstr(&vb,"/" INFODIR);
-  varbufaddstr(&vb,pkg->name);
-  varbufaddc(&vb,'.');
-  varbufaddstr(&vb,whichfile);
-  varbufaddc(&vb,0);
-  return vb.buf;
-}
-
-void cu_closepipe(int argc, void **argv) {
-  int *p1= (int*)argv[0];
-  close(p1[0]); close(p1[1]);
-}
-
-void cu_closefile(int argc, void **argv) {
-  FILE *f= (FILE*)(argv[0]);
-  fclose(f);
-}
-
-void cu_closefd(int argc, void **argv) {
-  int ip= *(int*)argv;
-  close(ip);
-}
-
 int pkglistqsortcmp(const void *a, const void *b) {
   const struct pkginfo *pa= *(const struct pkginfo**)a;
   const struct pkginfo *pb= *(const struct pkginfo**)b;