git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] http-push: update memory allocation for http headers

From
Ray Chuan <rctay89@gmail.com>
Date
Jan 18, 2009, 13:16 UTC
Message-ID
<be6fef0d0901180516q19327c18oa1d7ccc36ce3a87@mail.gmail.com>

In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the header strings were with the removal "opaquelocktoken:" (16 characters).

Unfortunately, this was without the corresponding change in memory allocation. In this patch we update these allocations.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 http-push.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/http-push.c b/http-push.c
index a4b7d08..a6522dd 100644
--- a/http-push.c
+++ b/http-push.c
@@ -595,7 +595,7 @@ static int refresh_lock(struct remote_lock *lock)

 	lock->refreshing = 1;

-	if_header = xmalloc(strlen(lock->token) + 25);
+	if_header = xmalloc(strlen(lock->token) + 9);
 	sprintf(if_header, "If: (<%s>)", lock->token);
 	sprintf(timeout_header, "Timeout: Second-%ld", lock->timeout);
 	dav_headers = curl_slist_append(dav_headers, if_header);
@@ -1306,7 +1306,7 @@ static int unlock_remote(struct remote_lock *lock)
 	struct curl_slist *dav_headers = NULL;
 	int rc = 0;

-	lock_token_header = xmalloc(strlen(lock->token) + 31);
+	lock_token_header = xmalloc(strlen(lock->token) + 15);
 	sprintf(lock_token_header, "Lock-Token: <%s>",
 		lock->token);
 	dav_headers = curl_slist_append(dav_headers, lock_token_header);
@@ -1730,7 +1730,7 @@ static int update_remote(unsigned char *sha1,
struct remote_lock *lock)
 	struct buffer out_buffer = { STRBUF_INIT, 0 };
 	struct curl_slist *dav_headers = NULL;

-	if_header = xmalloc(strlen(lock->token) + 25);
+	if_header = xmalloc(strlen(lock->token) + 9);
 	sprintf(if_header, "If: (<%s>)", lock->token);
 	dav_headers = curl_slist_append(dav_headers, if_header);

@@ -1949,7 +1949,7 @@ static void update_remote_info_refs(struct
remote_lock *lock)
 	remote_ls("refs/", (PROCESS_FILES | RECURSIVE),
 		  add_remote_info_ref, &buffer.buf);
 	if (!aborted) {
-		if_header = xmalloc(strlen(lock->token) + 25);
+		if_header = xmalloc(strlen(lock->token) + 9);
 		sprintf(if_header, "If: (<%s>)", lock->token);
 		dav_headers = curl_slist_append(dav_headers, if_header);
-- 
1.6.0.4
Next: Mike Hommey
Message 1 of 3 in “http-push: update memory allocation for http headers”
  1. http-push: update memory allocation for http headersRay Chuan, Jan 18, 2009
  2. Mike HommeyJan 18, 2009
  3. Johannes SchindelinJan 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.