diff options
author | Guillem Jover <guillem@debian.org> | 2017-05-15 06:45:14 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2017-05-17 06:30:15 +0200 |
commit | a6fbd1693e41d86db6884f1ce8b8576fcdeb7495 (patch) | |
tree | 19a16b6d9d49e7f251c132c68d25452c6a44c016 /lib | |
parent | 7c58bb402d7e57312f89efae4a9d811b9b29d11a (diff) | |
download | dpkg-a6fbd1693e41d86db6884f1ce8b8576fcdeb7495.tar.gz |
libdpkg: Do not parse device number for non block nor char tar entry objects
We should not try to parse these fields if the tar entry is neither
a block nor a char device.
On older tar entries these fields will be all NULs, so it would make
a parser expecting a somewhat strictly formatted octal value to error
out.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpkg/tarfn.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c index 608205315..ca921f0db 100644 --- a/lib/dpkg/tarfn.c +++ b/lib/dpkg/tarfn.c @@ -175,8 +175,12 @@ tar_header_decode(struct tar_header *h, struct tar_entry *d) d->stat.mode = tar_header_get_unix_mode(h); d->size = (off_t)tar_oct2int(h->size, sizeof(h->size)); d->mtime = (time_t)tar_oct2int(h->mtime, sizeof(h->mtime)); - d->dev = makedev(tar_oct2int(h->devmajor, sizeof(h->devmajor)), - tar_oct2int(h->devminor, sizeof(h->devminor))); + + if (d->type == TAR_FILETYPE_CHARDEV || d->type == TAR_FILETYPE_BLOCKDEV) + d->dev = makedev(tar_oct2int(h->devmajor, sizeof(h->devmajor)), + tar_oct2int(h->devminor, sizeof(h->devminor))); + else + d->dev = makedev(0, 0); if (*h->user) d->stat.uname = m_strndup(h->user, sizeof(h->user)); |