{"thread":{"id":"19684","subject":"[PATCH 03/23] http*: cleanup slot->local after fclose","startedAt":"2009-06-05T16:01:33Z","lastAt":"2009-06-06T01:15:21Z","messageCount":3,"participants":["Tay Ray Chuan","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":23},"messages":[{"id":"115520","messageId":"20090606000133.33101b1e.rctay89@gmail.com","threadId":"19684","inReplyTo":null,"subject":"[PATCH 03/23] http*: cleanup slot->local after fclose","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-05T16:01:33Z","receivedAt":"2009-06-05T16:01:33Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Set slot->local to NULL after doing a fclose on the FILE* pointer it\npoints to. This prevents an invalid FILE* pointer from being passed to\nftell() in http.c::run_active_slot().\n\nThis issue was raised by Clemens Buchacher on 30th May:\n\n  http://www.spinics.net/lists/git/msg104623.html\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nI've made it more clear what issue this patch is fixing.\n\n http-push.c   |    6 ++++++\n http-walker.c |    6 ++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex e16a0ad..0b12ffe 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -724,9 +724,11 @@ static void finish_request(struct transfer_request *request)\n \tstruct stat st;\n \tstruct packed_git *target;\n \tstruct packed_git **lst;\n+\tstruct active_request_slot *slot;\n\n \trequest->curl_result = request->slot->curl_result;\n \trequest->http_code = request->slot->http_code;\n+\tslot = request->slot;\n \trequest->slot = NULL;\n\n \t/* Keep locks active */\n@@ -823,6 +825,7 @@ static void finish_request(struct transfer_request *request)\n\n \t\t\tfclose(request->local_stream);\n \t\t\trequest->local_stream = NULL;\n+\t\t\tslot->local = NULL;\n \t\t\tif (!move_temp_to_file(request->tmpfile,\n \t\t\t\t\t       request->filename)) {\n \t\t\t\ttarget = (struct packed_git *)request->userData;\n@@ -1024,17 +1027,20 @@ static int fetch_index(unsigned char *sha1)\n \t\tif (results.curl_result != CURLE_OK) {\n \t\t\tfree(url);\n \t\t\tfclose(indexfile);\n+\t\t\tslot->local = NULL;\n \t\t\treturn error(\"Unable to get pack index %s\\n%s\", url,\n \t\t\t\t     curl_errorstr);\n \t\t}\n \t} else {\n \t\tfree(url);\n \t\tfclose(indexfile);\n+\t\tslot->local = NULL;\n \t\treturn error(\"Unable to start request\");\n \t}\n\n \tfree(url);\n \tfclose(indexfile);\n+\tslot->local = NULL;\n\n \treturn move_temp_to_file(tmpfile, filename);\n }\ndiff --git a/http-walker.c b/http-walker.c\nindex 7321ccc..9377851 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -418,15 +418,18 @@ static int fetch_index(struct walker *walker, struct alt_base *repo, unsigned ch\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result != CURLE_OK) {\n \t\t\tfclose(indexfile);\n+\t\t\tslot->local = NULL;\n \t\t\treturn error(\"Unable to get pack index %s\\n%s\", url,\n \t\t\t\t     curl_errorstr);\n \t\t}\n \t} else {\n \t\tfclose(indexfile);\n+\t\tslot->local = NULL;\n \t\treturn error(\"Unable to start request\");\n \t}\n\n \tfclose(indexfile);\n+\tslot->local = NULL;\n\n \treturn move_temp_to_file(tmpfile, filename);\n }\n@@ -776,16 +779,19 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha\n \t\trun_active_slot(slot);\n \t\tif (results.curl_result != CURLE_OK) {\n \t\t\tfclose(packfile);\n+\t\t\tslot->local = NULL;\n \t\t\treturn error(\"Unable to get pack file %s\\n%s\", url,\n \t\t\t\t     curl_errorstr);\n \t\t}\n \t} else {\n \t\tfclose(packfile);\n+\t\tslot->local = NULL;\n \t\treturn error(\"Unable to start request\");\n \t}\n\n \ttarget->pack_size = ftell(packfile);\n \tfclose(packfile);\n+\tslot->local = NULL;\n\n \tret = move_temp_to_file(tmpfile, filename);\n \tif (ret)\n--\n1.6.3.1\n"},{"id":"115562","messageId":"m3vdna5s3d.fsf@localhost.localdomain","threadId":"19684","inReplyTo":"20090606000133.33101b1e.rctay89@gmail.com","subject":"Re: [PATCH 03/23] http*: cleanup slot->local after fclose","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-05T20:43:53Z","receivedAt":"2009-06-05T20:43:53Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> Set slot->local to NULL after doing a fclose on the FILE* pointer it\n> points to. This prevents an invalid FILE* pointer from being passed to\n> ftell() in http.c::run_active_slot().\n\nYou mean here passing FILE* pointer to a fclosed file to ftell()?\n\n> \n> This issue was raised by Clemens Buchacher on 30th May:\n\nJust in case: 30th May 2009?\n\n> \n>   http://www.spinics.net/lists/git/msg104623.html\n> \n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"115592","messageId":"be6fef0d0906051815v7eb6cc65vf00830645bff6489@mail.gmail.com","threadId":"19684","inReplyTo":"m3vdna5s3d.fsf@localhost.localdomain","subject":"Re: [PATCH 03/23] http*: cleanup slot->local after fclose","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-06-06T01:15:21Z","receivedAt":"2009-06-06T01:15:21Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Jun 6, 2009 at 4:43 AM, Jakub Narebski<jnareb@gmail.com> wrote:\n> You mean here passing FILE* pointer to a fclosed file to ftell()?\n\nOk.\n\n> Just in case: 30th May 2009?\n\nYes.\n\n-- \nCheers,\nRay Chuan\n"}]}