The following commit has been merged in the master branch:
commit d8432dde9f3901370e0ff72b5bef2dda6e18d78f
Author: Guillem Jover <[email protected]>
Date: Thu Aug 13 21:24:35 2009 +0200
Use MD5HASHLEN instead of literals
diff --git a/TODO b/TODO
index 3bece83..254481f 100644
--- a/TODO
+++ b/TODO
@@ -42,7 +42,6 @@ ROADMAP
- Refactor packageslump into generic code.
- Refactor subprocess execution (argument building etc).
- Replace raw write and read calls with safe variants (signals etc).
- - Use MD5HASHLEN.
- Fix compress_type being shadowed.
- Fix stat variables being shadowed (bugs!!).
- Make deb build version a version instead of doing checks over a string.
diff --git a/dpkg-split/info.c b/dpkg-split/info.c
index 2962edd..3ea50e5 100644
--- a/dpkg-split/info.c
+++ b/dpkg-split/info.c
@@ -125,8 +125,8 @@ struct partinfo *read_info(FILE *partfile, const char *fn,
struct partinfo *ir)
ir->package = nfstrsave(nextline(&rip, fn, _("package name")));
ir->version = nfstrsave(nextline(&rip, fn, _("package version number")));
ir->md5sum = nfstrsave(nextline(&rip, fn, _("package file MD5 checksum")));
- if (strlen(ir->md5sum) != 32 ||
- strspn(ir->md5sum,"0123456789abcdef") != 32)
+ if (strlen(ir->md5sum) != MD5HASHLEN ||
+ strspn(ir->md5sum, "0123456789abcdef") != MD5HASHLEN)
ohshit(_("file `%.250s' is corrupt - bad MD5 checksum
`%.250s'"),fn,ir->md5sum);
ir->orglength = unsignedlong(nextline(&rip, fn, _("total length")), fn,
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index 105fce2..183598e 100644
--- a/dpkg-split/queue.c
+++ b/dpkg-split/queue.c
@@ -52,12 +52,14 @@ static int decompose_filename(const char *filename, struct
partqueue *pq) {
const char *p;
char *q;
- if (strspn(filename,"0123456789abcdef") != 32 || filename[32] != '.') return
0;
- q= nfmalloc(33);
- memcpy(q, filename, 32);
- q[32] = '\0';
+ if (strspn(filename, "0123456789abcdef") != MD5HASHLEN ||
+ filename[MD5HASHLEN] != '.')
+ return 0;
+ q = nfmalloc(MD5HASHLEN + 1);
+ memcpy(q, filename, MD5HASHLEN);
+ q[MD5HASHLEN] = '\0';
pq->info.md5sum= q;
- p= filename+33;
+ p = filename + MD5HASHLEN + 1;
pq->info.maxpartlen= strtol(p,&q,16); if (q==p || *q++ != '.') return 0;
p=q; pq->info.thispartn= (int)strtol(p,&q,16); if (q==p || *q++ != '.')
return 0;
p=q; pq->info.maxpartn= (int)strtol(p,&q,16); if (q==p || *q) return 0;
diff --git a/lib/dpkg/mlib.c b/lib/dpkg/mlib.c
index 0bab1ad..abe4d01 100644
--- a/lib/dpkg/mlib.c
+++ b/lib/dpkg/mlib.c
@@ -154,7 +154,7 @@ off_t buffer_write(buffer_data_t data, void *buf, off_t
length, const char *desc
int i;
unsigned char digest[16], *p = digest;
struct buffer_write_md5ctx *ctx = (struct buffer_write_md5ctx
*)data->data.ptr;
- unsigned char *hash = *ctx->hash = m_malloc(33);
+ unsigned char *hash = *ctx->hash = m_malloc(MD5HASHLEN + 1);
MD5Final(digest, &ctx->ctx);
for (i = 0; i < 16; ++i) {
sprintf((char *)hash, "%02x", *p++);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]