X-Git-Url: https://pd.if.org/git/?p=zpackage;a=blobdiff_plain;f=lib%2Fzpm.c;h=63ecc17632c46eefb37aa5137abe22421cb38c28;hp=3cc7632d76280dacb9e4be3957a1794415a7d4a5;hb=2ac486ab18adbbb84563eafc0d67fa8da6ca7822;hpb=4fb490d9107b747c86964d0d3925470b06d97c8c diff --git a/lib/zpm.c b/lib/zpm.c index 3cc7632..63ecc17 100644 --- a/lib/zpm.c +++ b/lib/zpm.c @@ -581,11 +581,9 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) { int fd; void *content = 0; struct stat sbuf; - unsigned char tmp[32]; - struct sha256_state md; sqlite3_stmt *ifile = 0; int haverow = 0,havedata = 0; - int j,rc,type; + int rc,type; char hashbuf[65]; /* xz compress it */ @@ -642,13 +640,7 @@ int zpm_import(struct zpm *zpm, char *path, uint32_t flags, char *hash) { return 0; } - /* get hash */ - sha256_init(&md); - sha256_process(&md, content, sbuf.st_size); - sha256_done(&md, tmp); - for (j=0;j<32;j++) { - sprintf(hash+j*2, "%02x", (unsigned)tmp[j]); - } + zpm_hash_mem(content, sbuf.st_size, hash); hash[64] = 0; /* TODO check null */