pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/45044: archivers/libarchive minix support



The following reply was made to PR pkg/45044; it has been noted by GNATS.

From: Thomas Cort <tcort%minix3.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: pkg/45044: archivers/libarchive minix support
Date: Thu, 16 Jun 2011 16:18:56 -0400

 I did a bulk build of all of the minix packages with the uid/gid overflow
 detection patch removed, and I did not run into any problems building
 the packages nor installing them. It appears that the patch I originally
 submitted is no longer needed. It was written about a year ago, and whatever
 was causing the problem appears to have been fixed by another change.
 
 We are still interested in displaying a warning when the UID/GID overflows.
 A patch to display a warning follows:
 
 
 diff --git 
a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c 
b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
 index dae13dc..f77ae14 100644
 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
 +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
 @@ -26,6 +26,9 @@
  #include "archive_platform.h"
  __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_tar.c 
201161 2009-12-29 05:44:39Z kientzle $");
  
 +#include <grp.h>
 +#include <pwd.h>
 +
  #ifdef HAVE_ERRNO_H
  #include <errno.h>
  #endif
 @@ -917,8 +920,11 @@ static int
  header_common(struct archive_read *a, struct tar *tar,
      struct archive_entry *entry, const void *h)
  {
 +      int err = ARCHIVE_OK;
        const struct archive_entry_header_ustar *header;
        char    tartype;
 +      uid_t uid;
 +      gid_t gid;
  
        (void)a; /* UNUSED */
  
 @@ -931,8 +937,41 @@ header_common(struct archive_read *a, struct tar *tar,
  
        /* Parse out the numeric fields (all are octal) */
        archive_entry_set_mode(entry, tar_atol(header->mode, 
sizeof(header->mode)));
 -      archive_entry_set_uid(entry, tar_atol(header->uid, 
sizeof(header->uid)));
 -      archive_entry_set_gid(entry, tar_atol(header->gid, 
sizeof(header->gid)));
 +
 +      uid = (uid_t) tar_atol(header->uid, sizeof(header->uid));
 +
 +      /* Sanity check: uid overflow. Some systems have a limited uid_t.
 +       * For example, Minix 3.2.0 has 16-bit uids.
 +       */
 +      if (uid != tar_atol(header->uid, sizeof(header->uid))) {
 +
 +              archive_set_error(&a->archive, EINVAL,
 +                      "uid %ld out of range; will be extracted as %d.",
 +                      tar_atol(header->uid, sizeof(header->uid)),
 +                      uid);
 +
 +              err = ARCHIVE_WARN;
 +      }
 +
 +      archive_entry_set_uid(entry, uid);
 +
 +      gid = (gid_t) tar_atol(header->gid, sizeof(header->gid));
 +
 +      /* Sanity check: gid overflow. Some systems have a limited gid_t.
 +       * For example, Minix 3.2.0 has 8-bit gids.
 +       */
 +      if (gid != tar_atol(header->gid, sizeof(header->gid))) {
 +
 +              archive_set_error(&a->archive, EINVAL,
 +                      "gid %ld out of range; will be extracted as %d",
 +                      tar_atol(header->gid, sizeof(header->gid)),
 +                      gid);
 +
 +              err = ARCHIVE_WARN;
 +      }
 +
 +      archive_entry_set_gid(entry, gid);
 +
        tar->entry_bytes_remaining = tar_atol(header->size, 
sizeof(header->size));
        tar->realsize = tar->entry_bytes_remaining;
        archive_entry_set_size(entry, tar->entry_bytes_remaining);
 @@ -1063,7 +1102,8 @@ header_common(struct archive_read *a, struct tar *tar,
                archive_entry_set_filetype(entry, AE_IFREG);
                break;
        }
 -      return (0);
 +
 +      return err;
  }
  
  /*
 @@ -1073,6 +1113,7 @@ static int
  header_old_tar(struct archive_read *a, struct tar *tar,
      struct archive_entry *entry, const void *h)
  {
 +      int err;
        const struct archive_entry_header_ustar *header;
  
        /* Copy filename over (to ensure null termination). */
 @@ -1081,10 +1122,10 @@ header_old_tar(struct archive_read *a, struct tar *tar,
        archive_entry_copy_pathname(entry, tar->entry_pathname.s);
  
        /* Grab rest of common fields */
 -      header_common(a, tar, entry, h);
 +      err = header_common(a, tar, entry, h);
  
        tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
 -      return (0);
 +      return err;
  }
  
  /*
 @@ -1143,6 +1184,7 @@ static int
  header_ustar(struct archive_read *a, struct tar *tar,
      struct archive_entry *entry, const void *h)
  {
 +      int err;
        const struct archive_entry_header_ustar *header;
        struct archive_string *as;
  
 @@ -1161,7 +1203,7 @@ header_ustar(struct archive_read *a, struct tar *tar,
        archive_entry_copy_pathname(entry, as->s);
  
        /* Handle rest of common fields. */
 -      header_common(a, tar, entry, h);
 +      err = header_common(a, tar, entry, h);
  
        /* Handle POSIX ustar fields. */
        archive_strncpy(&(tar->entry_uname), header->uname,
 @@ -1182,7 +1224,7 @@ header_ustar(struct archive_read *a, struct tar *tar,
  
        tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
  
 -      return (0);
 +      return err;
  }
  
  
 @@ -1662,6 +1704,7 @@ static int
  header_gnutar(struct archive_read *a, struct tar *tar,
      struct archive_entry *entry, const void *h)
  {
 +      int err;
        const struct archive_entry_header_gnutar *header;
  
        (void)a;
 @@ -1673,7 +1716,7 @@ header_gnutar(struct archive_read *a, struct tar *tar,
         */
  
        /* Grab fields common to all tar variants. */
 -      header_common(a, tar, entry, h);
 +      err = header_common(a, tar, entry, h);
  
        /* Copy filename over (to ensure null termination). */
        header = (const struct archive_entry_header_gnutar *)h;
 @@ -1723,7 +1766,7 @@ header_gnutar(struct archive_read *a, struct tar *tar,
                }
        }
  
 -      return (0);
 +      return err;
  }
  
  static void
 


Home | Main Index | Thread Index | Old Index