tar: fix checksum calculation (signed/unsigned issue)
some archives gave the error: "malformed tar archive" test file where this occurred: http://nl.alpinelinux.org/alpine/v3.1/main/x86_64/apk-tools-static-2.5.0_rc1-r0.apk
This commit is contained in:
parent
29649762b3
commit
deb8a16527
4
tar.c
4
tar.c
|
@ -237,7 +237,7 @@ archive(const char *path)
|
|||
|
||||
memset(h->chksum, ' ', sizeof(h->chksum));
|
||||
for (i = 0, chksum = 0; i < sizeof(*h); i++)
|
||||
chksum += b[i];
|
||||
chksum += (unsigned char)b[i];
|
||||
putoctal(h->chksum, chksum, sizeof(h->chksum));
|
||||
ewrite(tarfd, b, BLKSIZ);
|
||||
|
||||
|
@ -412,7 +412,7 @@ chktar(struct header *h)
|
|||
goto bad;
|
||||
memset(h->chksum, ' ', sizeof(h->chksum));
|
||||
for (i = 0, s2 = 0; i < sizeof(*h); i++)
|
||||
s2 += p[i];
|
||||
s2 += (unsigned char)p[i];
|
||||
if (s1 != s2)
|
||||
goto bad;
|
||||
memcpy(h->chksum, tmp, sizeof(h->chksum));
|
||||
|
|
Loading…
Reference in New Issue
Block a user