{"thread":{"id":"17236","subject":"[PATCH] http-push: update memory allocation for http headers","startedAt":"2009-01-18T13:16:04Z","lastAt":"2009-01-18T14:55:30Z","messageCount":3,"participants":["Ray Chuan","Mike Hommey","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"100961","messageId":"be6fef0d0901180516q19327c18oa1d7ccc36ce3a87@mail.gmail.com","threadId":"17236","inReplyTo":null,"subject":"[PATCH] http-push: update memory allocation for http headers","fromName":"Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-01-18T13:16:04Z","receivedAt":"2009-01-18T13:16:04Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the\nheader strings were with the removal \"opaquelocktoken:\" (16\ncharacters).\n\nUnfortunately, this was without the corresponding change in memory\nallocation. In this patch we update these allocations.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http-push.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex a4b7d08..a6522dd 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -595,7 +595,7 @@ static int refresh_lock(struct remote_lock *lock)\n\n \tlock->refreshing = 1;\n\n-\tif_header = xmalloc(strlen(lock->token) + 25);\n+\tif_header = xmalloc(strlen(lock->token) + 9);\n \tsprintf(if_header, \"If: (<%s>)\", lock->token);\n \tsprintf(timeout_header, \"Timeout: Second-%ld\", lock->timeout);\n \tdav_headers = curl_slist_append(dav_headers, if_header);\n@@ -1306,7 +1306,7 @@ static int unlock_remote(struct remote_lock *lock)\n \tstruct curl_slist *dav_headers = NULL;\n \tint rc = 0;\n\n-\tlock_token_header = xmalloc(strlen(lock->token) + 31);\n+\tlock_token_header = xmalloc(strlen(lock->token) + 15);\n \tsprintf(lock_token_header, \"Lock-Token: <%s>\",\n \t\tlock->token);\n \tdav_headers = curl_slist_append(dav_headers, lock_token_header);\n@@ -1730,7 +1730,7 @@ static int update_remote(unsigned char *sha1,\nstruct remote_lock *lock)\n \tstruct buffer out_buffer = { STRBUF_INIT, 0 };\n \tstruct curl_slist *dav_headers = NULL;\n\n-\tif_header = xmalloc(strlen(lock->token) + 25);\n+\tif_header = xmalloc(strlen(lock->token) + 9);\n \tsprintf(if_header, \"If: (<%s>)\", lock->token);\n \tdav_headers = curl_slist_append(dav_headers, if_header);\n\n@@ -1949,7 +1949,7 @@ static void update_remote_info_refs(struct\nremote_lock *lock)\n \tremote_ls(\"refs/\", (PROCESS_FILES | RECURSIVE),\n \t\t  add_remote_info_ref, &buffer.buf);\n \tif (!aborted) {\n-\t\tif_header = xmalloc(strlen(lock->token) + 25);\n+\t\tif_header = xmalloc(strlen(lock->token) + 9);\n \t\tsprintf(if_header, \"If: (<%s>)\", lock->token);\n \t\tdav_headers = curl_slist_append(dav_headers, if_header);\n\n-- \n1.6.0.4\n"},{"id":"100968","messageId":"20090118142002.GA18159@glandium.org","threadId":"17236","inReplyTo":"be6fef0d0901180516q19327c18oa1d7ccc36ce3a87@mail.gmail.com","subject":"Re: [PATCH] http-push: update memory allocation for http headers","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2009-01-18T14:20:02Z","receivedAt":"2009-01-18T14:20:02Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sun, Jan 18, 2009 at 09:16:04PM +0800, Ray Chuan wrote:\n> In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the\n> header strings were with the removal \"opaquelocktoken:\" (16\n> characters).\n> \n> Unfortunately, this was without the corresponding change in memory\n> allocation. In this patch we update these allocations.\n> \n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n\nIt would be better to just turn the whole thing to use strbuf, and/or\nextend the patch set I sent earlier today to handle webdav.\n\nMike\n"},{"id":"100982","messageId":"alpine.DEB.1.00.0901181554480.3586@pacific.mpi-cbg.de","threadId":"17236","inReplyTo":"be6fef0d0901180516q19327c18oa1d7ccc36ce3a87@mail.gmail.com","subject":"Re: [PATCH] http-push: update memory allocation for http headers","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-18T14:55:30Z","receivedAt":"2009-01-18T14:55:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 18 Jan 2009, Ray Chuan wrote:\n\n> In 753bc91 (Remove the requirement opaquelocktoken uri scheme), the\n> header strings were with the removal \"opaquelocktoken:\" (16\n> characters).\n> \n> Unfortunately, this was without the corresponding change in memory\n> allocation. In this patch we update these allocations.\n\nRather than doing this (which will result in as error-prone code), why \ndon't you replace those things by strbufs?\n\nCiao,\nDscho\n"}]}