summaryrefslogtreecommitdiff
path: root/dpkg-deb
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2013-08-28 03:00:16 +0200
committerGuillem Jover <guillem@debian.org>2013-10-17 08:22:06 +0200
commit8911538401d79c17ea347de91ef131365aa86934 (patch)
treed289a452c20b3e65cc858131af58de7e4f0f8f99 /dpkg-deb
parent240330b3738c2374c916ff225a86b039860ddbc1 (diff)
downloaddpkg-8911538401d79c17ea347de91ef131365aa86934.tar.gz
dpkg-deb: Be explicit when handling deb format 2 code branches
Test against an explicit major version 2 instead of just assuming the alternate branch of major version 0 will be 2. This is more future-proof and makes the code clearer. Reported-by: Jérémy Bobbio <lunar@debian.org>
Diffstat (limited to 'dpkg-deb')
-rw-r--r--dpkg-deb/build.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 389c5528d..b67058c1f 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -509,13 +509,16 @@ do_build(const char *const *argv)
if (fd_fd_copy(gzfd, arfd, -1, &err) < 0)
ohshit(_("cannot copy '%s' into archive '%s': %s"), _("control member"),
debar, err.str);
- } else {
+ } else if (deb_format.major == 2) {
const char deb_magic[] = ARCHIVEVERSION "\n";
dpkg_ar_put_magic(debar, arfd);
dpkg_ar_member_put_mem(debar, arfd, DEBMAGIC, deb_magic, strlen(deb_magic));
dpkg_ar_member_put_file(debar, arfd, ADMINMEMBER, gzfd, -1);
+ } else {
+ internerr("unknown deb format version %d.%d", deb_format.major, deb_format.minor);
}
+
close(gzfd);
/* Control is done, now we need to archive the data. */
@@ -524,7 +527,7 @@ do_build(const char *const *argv)
* control member, so we do not need a temporary file and can use
* the compression file descriptor. */
gzfd = arfd;
- } else {
+ } else if (deb_format.major == 2) {
/* Start by creating a new temporary file. Immediately unlink the
* temporary file so others can't mess with it. */
tfbuf = path_make_temp_template("dpkg-deb");
@@ -536,6 +539,8 @@ do_build(const char *const *argv)
ohshit(_("failed to unlink temporary file (%s), %s"), _("data member"),
tfbuf);
free(tfbuf);
+ } else {
+ internerr("unknown deb format version %d.%d", deb_format.major, deb_format.minor);
}
/* Fork off a tar. We will feed it a list of filenames on stdin later. */
m_pipe(p1);