Browse Source

libdpkg: Normalize tar_filetype_file0 to tar_filetype_file on decode

Guillem Jover 16 years ago
parent
commit
646892a232
2 changed files with 4 additions and 6 deletions
  1. 2 1
      lib/dpkg/tarfn.c
  2. 2 5
      src/archives.c

+ 2 - 1
lib/dpkg/tarfn.c

@@ -129,6 +129,8 @@ DecodeTarHeader(char *block, struct TarInfo *d)
 		d->format = tar_format_old;
 
 	d->Type = (enum tar_filetype)h->LinkFlag;
+	if (d->Type == tar_filetype_file0)
+		d->Type = tar_filetype_file;
 
 	if (*h->UserName)
 		passwd = getpwnam(h->UserName);
@@ -233,7 +235,6 @@ TarExtractor(void *ctx, const struct tar_operations *ops)
 		nameLength = strlen(h.Name);
 
 		switch (h.Type) {
-		case tar_filetype_file0:
 		case tar_filetype_file:
 			/* Compatibility with pre-ANSI ustar. */
 			if (h.Name[nameLength - 1] != '/') {

+ 2 - 5
src/archives.c

@@ -188,7 +188,7 @@ tarfile_skip_one_forward(struct tarcontext *tc, struct TarInfo *ti)
   /* We need to advance the tar file to the next object, so read the
    * file data and set it to oblivion.
    */
-  if ((ti->Type == tar_filetype_file0) || (ti->Type == tar_filetype_file)) {
+  if (ti->Type == tar_filetype_file) {
     char fnamebuf[256];
 
     fd_null_copy(tc->backendpipe, ti->Size,
@@ -425,7 +425,6 @@ tarobject(void *ctx, struct TarInfo *ti)
         "tarobject ti->Name=`%s' Mode=%lo owner=%u.%u Type=%d(%c)"
         " ti->LinkName=`%s' namenode=`%s' flags=%o instead=`%s'",
         ti->Name, (long)ti->Mode, (unsigned)ti->UserID, (unsigned)ti->GroupID, ti->Type,
-        ti->Type == '\0' ? '_' :
         ti->Type >= '0' && ti->Type <= '6' ? "-hlcbdp"[ti->Type - '0'] : '?',
         ti->LinkName,
         nifd->namenode->name, nifd->namenode->flags,
@@ -513,7 +512,6 @@ tarobject(void *ctx, struct TarInfo *ti)
       existingdirectory = true;
     }
     break;
-  case tar_filetype_file0:
   case tar_filetype_file:
   case tar_filetype_chardev:
   case tar_filetype_blockdev:
@@ -657,7 +655,6 @@ tarobject(void *ctx, struct TarInfo *ti)
 
   /* Extract whatever it is as .dpkg-new ... */
   switch (ti->Type) {
-  case tar_filetype_file0:
   case tar_filetype_file:
     /* We create the file with mode 0 to make sure nobody can do anything with
      * it until we apply the proper mode, which might be a statoverride.
@@ -812,7 +809,7 @@ tarobject(void *ctx, struct TarInfo *ti)
    * in dpkg-new.
    */
 
-  if (ti->Type == tar_filetype_file0 || ti->Type == tar_filetype_file) {
+  if (ti->Type == tar_filetype_file) {
     nifd->namenode->flags |= fnnf_deferred_rename;
 
     debug(dbg_eachfiledetail, "tarobject done and installation deferred");