diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-17 12:02:18 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-08-17 12:07:00 +0000 |
commit | 1ccf8652da6371103f5f680f45ec3fdd1acd9df0 (patch) | |
tree | 3d7392f6a75b536850e46cece236235c8d05c3cd | |
parent | 97030974d9a9e08b863cba3b89478f929c870abf (diff) | |
download | abuild-1ccf8652da6371103f5f680f45ec3fdd1acd9df0.tar.gz abuild-1ccf8652da6371103f5f680f45ec3fdd1acd9df0.tar.bz2 abuild-1ccf8652da6371103f5f680f45ec3fdd1acd9df0.tar.xz abuild-1ccf8652da6371103f5f680f45ec3fdd1acd9df0.zip |
Revert "abuild-tar: embed checksum for symlinks"
Tar could not handle the headers.
This reverts parts of commit 8b1a53011b3aa56594e785c425b318c21fba8684.
Keep the usage fixes.
-rw-r--r-- | abuild-tar.c | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/abuild-tar.c b/abuild-tar.c index 011fff6..1b6e2fb 100644 --- a/abuild-tar.c +++ b/abuild-tar.c @@ -42,8 +42,6 @@ struct tar_header { char padding[12]; /* 500-512 */ }; -#define MAX_MD_SIZE 20 - #define GET_OCTAL(s) get_octal(s, sizeof(s)) #define PUT_OCTAL(s,v) put_octal(s, sizeof(s), v) @@ -175,7 +173,7 @@ static int do_it(const EVP_MD *md, int cut) struct tar_header hdr; size_t size, aligned_size; void *ptr; - int r; + int dohash = 0, r; struct { char id[4]; uint16_t nid; @@ -195,34 +193,22 @@ static int do_it(const EVP_MD *md, int cut) if (cut && hdr.name[0] == 0) return 0; - ptr = NULL; size = GET_OCTAL(hdr.size); aligned_size = (size + 511) & ~511; - if (md != NULL && - (hdr.typeflag == '0' || hdr.typeflag == '2' || - hdr.typeflag == '7')) { + if (md != NULL) + dohash = (hdr.typeflag == '0' || hdr.typeflag == '7'); + if (dohash) { const unsigned char *src; - unsigned char csdata[MAX_MD_SIZE]; int chksum, i; - if (hdr.typeflag == '0' || hdr.typeflag == '7') { - ptr = malloc(aligned_size); - if (full_read(STDIN_FILENO, ptr, aligned_size) - != aligned_size) - return 1; - - memcpy(&hdr.linkname[3], &mdinfo, sizeof(mdinfo)); - EVP_Digest(ptr, size, csdata, NULL, md, NULL); - } else { - EVP_Digest(hdr.linkname, strlen(hdr.linkname), - csdata, NULL, md, NULL); - } + ptr = malloc(aligned_size); + if (full_read(STDIN_FILENO, ptr, aligned_size) != aligned_size) + return 1; - /* Embed to header */ - memcpy(&hdr.devmajor, &mdinfo, sizeof(hdr.devmajor)); - memcpy(&hdr.devminor, &csdata[0], sizeof(hdr.devminor)); - memcpy(&hdr.padding, &csdata[sizeof(hdr.devminor)], sizeof(hdr.padding)); + memcpy(&hdr.linkname[3], &mdinfo, sizeof(mdinfo)); + EVP_Digest(ptr, size, &hdr.linkname[3+sizeof(mdinfo)], + NULL, md, NULL); /* Recalculate checksum */ memset(hdr.chksum, ' ', sizeof(hdr.chksum)); @@ -235,7 +221,7 @@ static int do_it(const EVP_MD *md, int cut) if (full_write(STDOUT_FILENO, &hdr, sizeof(hdr)) != sizeof(hdr)) return 2; - if (ptr != NULL) { + if (dohash) { if (full_write(STDOUT_FILENO, ptr, aligned_size) != aligned_size) return 2; free(ptr); @@ -285,10 +271,6 @@ int main(int argc, char **argv) md = EVP_get_digestbyname(digest); if (md == NULL) return usage(); - if (EVP_MD_size(md) > MAX_MD_SIZE) { - fprintf(stderr, "digest size is too large\n"); - return -1; - } } return do_it(md, cut); |