Browse Source

libdpkg: Use makedev(3) rather than ad-hoc computations

The current code does not support large major/minor device numbers, by
using the system's makedev(3) we'll be able to use those. This affects
at least Linux, NetBSD and OpenBSD based systems. In case the function
is not available (such as in Mac OS X), we'll fallback to the compat
implementation with the same current limitations.

Signed-off-by: Peter Chang <dpf@google.com>
Signed-off-by: Guillem Jover <guillem@debian.org>
Peter Chang 12 years ago
parent
commit
c9dd5ddbc9
2 changed files with 6 additions and 2 deletions
  1. 4 0
      debian/changelog
  2. 2 2
      lib/dpkg/tarfn.c

+ 4 - 0
debian/changelog

@@ -18,6 +18,10 @@ dpkg (1.17.6) UNRELEASED; urgency=low
   * Mention Multi-Arch: no value in man pages. Closes: #732648
   * Correctly hyphenate binary-only and source-only in dpkg-buildpackage
     output messages.
+  * Use makedev(3) when extracting .deb archives rather than ad-hoc
+    computations, to be able to support large major/minor device numbers,
+    supported on at least Linux, NetBSD and OpenBSD based systems.
+    Thanks to Peter Chang <dpf@google.com>.
 
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).

+ 2 - 2
lib/dpkg/tarfn.c

@@ -179,8 +179,8 @@ tar_header_decode(struct tar_header *h, struct tar_entry *d)
 	d->stat.mode = get_unix_mode(h);
 	d->size = (off_t)OtoM(h->size, sizeof(h->size));
 	d->mtime = (time_t)OtoM(h->mtime, sizeof(h->mtime));
-	d->dev = ((OtoM(h->devmajor, sizeof(h->devmajor)) & 0xff) << 8) |
-	         (OtoM(h->devminor, sizeof(h->devminor)) & 0xff);
+	d->dev = makedev(OtoM(h->devmajor, sizeof(h->devmajor)),
+			 OtoM(h->devminor, sizeof(h->devminor)));
 
 	if (*h->user)
 		passwd = getpwnam(h->user);