From ec99c9a89a65749093e16aed37d393f646597b31 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 3 Aug 2011 19:54:03 +0800 Subject: http.c: fix an invalid free() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove a free() on the static buffer returned by sha1_file_name(). While we're at it, replace xmalloc() calls on the structs http_(object|pack)_request with xcalloc() so that pointers in the structs get initialized to NULL. That way, free()'s are safe - for example, a free() on the url string member when aborting. This fixes an invalid free(). Reported-by: Ævar Arnfjörð Bjarmason Helped-by: Jeff King peff@peff.net Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- http.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index b27bb57d62..7e19e876b0 100644 --- a/http.c +++ b/http.c @@ -1116,9 +1116,8 @@ struct http_pack_request *new_http_pack_request( struct strbuf buf = STRBUF_INIT; struct http_pack_request *preq; - preq = xmalloc(sizeof(*preq)); + preq = xcalloc(1, sizeof(*preq)); preq->target = target; - preq->range_header = NULL; end_url_with_slash(&buf, base_url); strbuf_addf(&buf, "objects/pack/pack-%s.pack", @@ -1210,7 +1209,7 @@ struct http_object_request *new_http_object_request(const char *base_url, struct curl_slist *range_header = NULL; struct http_object_request *freq; - freq = xmalloc(sizeof(*freq)); + freq = xcalloc(1, sizeof(*freq)); hashcpy(freq->sha1, sha1); freq->localfile = -1; @@ -1248,8 +1247,6 @@ struct http_object_request *new_http_object_request(const char *base_url, goto abort; } - memset(&freq->stream, 0, sizeof(freq->stream)); - git_inflate_init(&freq->stream); git_SHA1_Init(&freq->c); @@ -1324,7 +1321,6 @@ struct http_object_request *new_http_object_request(const char *base_url, return freq; abort: - free(filename); free(freq->url); free(freq); return NULL; -- cgit v1.2.3 From d24d905509207fb47abe654789e1248a18785dfc Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 3 Aug 2011 20:07:57 +0800 Subject: Makefile: some changes for http-related flag documentation Rename git-http-pull to git-http-fetch. This was passed over in 215a7ad (Big tool rename, Wed Sep 7 17:26:23 2005 -0700). Also, distinguish between dumb and smart in flag docs, as the "warnings" in NO_CURL and NO_EXPACT are no longer accurate given the introduction of smart http(s). Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d2e2ea1c4f..c07aa9a72b 100644 --- a/Makefile +++ b/Makefile @@ -24,15 +24,15 @@ all:: # Define NO_OPENSSL environment variable if you do not have OpenSSL. # This also implies BLK_SHA1. # -# Define NO_CURL if you do not have libcurl installed. git-http-pull and +# Define NO_CURL if you do not have libcurl installed. git-http-fetch and # git-http-push are not built, and you cannot use http:// and https:// -# transports. +# transports (neither smart nor dumb). # # Define CURLDIR=/foo/bar if your curl header and library files are in # /foo/bar/include and /foo/bar/lib directories. # # Define NO_EXPAT if you do not have expat installed. git-http-push is -# not built, and you cannot push using http:// and https:// transports. +# not built, and you cannot push using http:// and https:// transports (dumb). # # Define EXPATDIR=/foo/bar if your expat header and library files are in # /foo/bar/include and /foo/bar/lib directories. -- cgit v1.2.3