The following commit has been merged in the master branch:
commit c81a1475db83f6fbd33a104085434f71d9761c74
Author: Guillem Jover <[email protected]>
Date: Thu Jul 1 12:05:09 2010 +0200
Use new DPKG_AR_MAGIC macro instead of literal string
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 03e5966..ccaae00 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -45,6 +45,7 @@
#include <dpkg/buffer.h>
#include <dpkg/subproc.h>
#include <dpkg/compress.h>
+#include <dpkg/ar.h>
#include <dpkg/myopt.h>
#include "dpkg-deb.h"
@@ -428,7 +429,7 @@ void do_build(const char *const *argv) {
} else {
thetime = time(NULL);
if (fprintf(ar,
- "!<arch>\n"
+ DPKG_AR_MAGIC
"%-16s%-12lu0 0 100644 %-10ld`\n"
ARCHIVEVERSION "\n"
"%s"
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index ee09b16..e5e1f9c 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -133,7 +133,7 @@ void extracthalf(const char *debar, const char *directory,
if (fstat(fileno(ar),&stab)) ohshite(_("failed to fstat archive"));
if (!fgets(versionbuf,sizeof(versionbuf),ar)) readfail(ar,debar,_("version
number"));
- if (!strcmp(versionbuf,"!<arch>\n")) {
+ if (!strcmp(versionbuf, DPKG_AR_MAGIC)) {
oldformat = false;
ctrllennum= 0;
diff --git a/dpkg-split/info.c b/dpkg-split/info.c
index 6b783f8..35d476c 100644
--- a/dpkg-split/info.c
+++ b/dpkg-split/info.c
@@ -84,7 +84,7 @@ struct partinfo *read_info(FILE *partfile, const char *fn,
struct partinfo *ir)
size_t thisilen;
unsigned int templong;
- char magicbuf[SARMAG], *rip, *partnums, *slash;
+ char magicbuf[strlen(DPKG_AR_MAGIC)], *rip, *partnums, *slash;
struct ar_hdr arh;
int c;
struct stat stab;
@@ -92,7 +92,7 @@ struct partinfo *read_info(FILE *partfile, const char *fn,
struct partinfo *ir)
if (fread(magicbuf, 1, sizeof(magicbuf), partfile) != sizeof(magicbuf)) {
if (ferror(partfile)) rerr(fn); else return NULL;
}
- if (memcmp(magicbuf, "!<arch>\n", sizeof(magicbuf)))
+ if (memcmp(magicbuf, DPKG_AR_MAGIC, sizeof(magicbuf)))
return NULL;
if (fread(&arh,1,sizeof(arh),partfile) != sizeof(arh)) rerreof(partfile,fn);
@@ -173,9 +173,9 @@ struct partinfo *read_info(FILE *partfile, const char *fn,
struct partinfo *ir)
? ir->orglength - ir->thispartoffset : ir->maxpartlen))
ohshit(_("file `%.250s' is corrupt - size is wrong for quoted part
number"),fn);
- ir->filesize= (SARMAG +
- sizeof(arh) + thisilen + (thisilen&1) +
- sizeof(arh) + ir->thispartlen + (ir->thispartlen&1));
+ ir->filesize = (strlen(DPKG_AR_MAGIC) +
+ sizeof(arh) + thisilen + (thisilen & 1) +
+ sizeof(arh) + ir->thispartlen + (ir->thispartlen & 1));
if (fstat(fileno(partfile),&stab)) ohshite(_("unable to fstat part file
`%.250s'"),fn);
if (S_ISREG(stab.st_mode)) {
@@ -186,7 +186,8 @@ struct partinfo *read_info(FILE *partfile, const char *fn,
struct partinfo *ir)
ohshit(_("file `%.250s' is corrupt - too short"),fn);
}
- ir->headerlen= SARMAG + sizeof(arh) + thisilen + (thisilen&1) + sizeof(arh);
+ ir->headerlen = strlen(DPKG_AR_MAGIC) +
+ sizeof(arh) + thisilen + (thisilen & 1) + sizeof(arh);
return ir;
}
diff --git a/lib/dpkg/ar.h b/lib/dpkg/ar.h
index 367ac72..80ea478 100644
--- a/lib/dpkg/ar.h
+++ b/lib/dpkg/ar.h
@@ -27,6 +27,8 @@
DPKG_BEGIN_DECLS
+#define DPKG_AR_MAGIC "!<arch>\n"
+
void dpkg_ar_normalize_name(struct ar_hdr *arh);
DPKG_END_DECLS
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]