From: Junio C Hamano Date: Thu, 22 Jan 2009 00:55:17 +0000 (-0800) Subject: Merge branch 'lt/maint-wrap-zlib' X-Git-Tag: v1.6.2-rc0~103 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=36dd9393938d4e7f8843c6c587c9b4db077377fc;p=git.git Merge branch 'lt/maint-wrap-zlib' * lt/maint-wrap-zlib: Wrap inflate and other zlib routines for better error reporting Conflicts: http-push.c http-walker.c sha1_file.c --- 36dd9393938d4e7f8843c6c587c9b4db077377fc diff --cc http-push.c index 6ad853e2d,6d977ea6e..cb5bf95a7 --- a/http-push.c +++ b/http-push.c @@@ -209,8 -208,8 +209,8 @@@ static size_t fwrite_sha1_file(void *pt do { request->stream.next_out = expn; request->stream.avail_out = sizeof(expn); - request->zret = inflate(&request->stream, Z_SYNC_FLUSH); + request->zret = git_inflate(&request->stream, Z_SYNC_FLUSH); - SHA1_Update(&request->c, expn, + git_SHA1_Update(&request->c, expn, sizeof(expn) - request->stream.avail_out); } while (request->stream.avail_in && request->zret == Z_OK); data_received++; @@@ -269,9 -268,9 +269,9 @@@ static void start_fetch_loose(struct tr memset(&request->stream, 0, sizeof(request->stream)); - inflateInit(&request->stream); + git_inflate_init(&request->stream); - SHA1_Init(&request->c); + git_SHA1_Init(&request->c); url = xmalloc(strlen(remote->url) + 50); request->url = xmalloc(strlen(remote->url) + 50); @@@ -310,8 -309,8 +310,8 @@@ file; also rewind to the beginning of the local file. */ if (prev_read == -1) { memset(&request->stream, 0, sizeof(request->stream)); - inflateInit(&request->stream); + git_inflate_init(&request->stream); - SHA1_Init(&request->c); + git_SHA1_Init(&request->c); if (prev_posn>0) { prev_posn = 0; lseek(request->local_fileno, 0, SEEK_SET); @@@ -742,8 -741,8 +742,8 @@@ static void finish_request(struct trans if (request->http_code == 416) fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n"); - inflateEnd(&request->stream); + git_inflate_end(&request->stream); - SHA1_Final(request->real_sha1, &request->c); + git_SHA1_Final(request->real_sha1, &request->c); if (request->zret != Z_STREAM_END) { unlink(request->tmpfile); } else if (hashcmp(request->obj->sha1, request->real_sha1)) { diff --cc http-walker.c index 7271c7d19,747d3adef..0dbad3c88 --- a/http-walker.c +++ b/http-walker.c @@@ -82,8 -82,8 +82,8 @@@ static size_t fwrite_sha1_file(void *pt do { obj_req->stream.next_out = expn; obj_req->stream.avail_out = sizeof(expn); - obj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH); + obj_req->zret = git_inflate(&obj_req->stream, Z_SYNC_FLUSH); - SHA1_Update(&obj_req->c, expn, + git_SHA1_Update(&obj_req->c, expn, sizeof(expn) - obj_req->stream.avail_out); } while (obj_req->stream.avail_in && obj_req->zret == Z_OK); data_received++; @@@ -142,9 -142,9 +142,9 @@@ static void start_object_request(struc memset(&obj_req->stream, 0, sizeof(obj_req->stream)); - inflateInit(&obj_req->stream); + git_inflate_init(&obj_req->stream); - SHA1_Init(&obj_req->c); + git_SHA1_Init(&obj_req->c); url = xmalloc(strlen(obj_req->repo->base) + 51); obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51); @@@ -183,8 -183,8 +183,8 @@@ file; also rewind to the beginning of the local file. */ if (prev_read == -1) { memset(&obj_req->stream, 0, sizeof(obj_req->stream)); - inflateInit(&obj_req->stream); + git_inflate_init(&obj_req->stream); - SHA1_Init(&obj_req->c); + git_SHA1_Init(&obj_req->c); if (prev_posn>0) { prev_posn = 0; lseek(obj_req->local, 0, SEEK_SET); @@@ -243,8 -243,8 +243,8 @@@ static void finish_object_request(struc return; } - inflateEnd(&obj_req->stream); + git_inflate_end(&obj_req->stream); - SHA1_Final(obj_req->real_sha1, &obj_req->c); + git_SHA1_Final(obj_req->real_sha1, &obj_req->c); if (obj_req->zret != Z_STREAM_END) { unlink(obj_req->tmpfile); return; diff --cc sha1_file.c index f08493f03,71c2282c9..360f7e5a0 --- a/sha1_file.c +++ b/sha1_file.c @@@ -1356,11 -1342,9 +1356,11 @@@ unsigned long get_size_from_delta(struc curpos += stream.next_in - in; } while ((st == Z_OK || st == Z_BUF_ERROR) && stream.total_out < sizeof(delta_head)); - inflateEnd(&stream); + git_inflate_end(&stream); - if ((st != Z_STREAM_END) && stream.total_out != sizeof(delta_head)) - die("delta data unpack-initial failed"); + if ((st != Z_STREAM_END) && stream.total_out != sizeof(delta_head)) { + error("delta data unpack-initial failed"); + return 0; + } /* Examine the initial part of the delta to figure out * the result size.