{"thread":{"id":"2703","subject":"[PATCH] Fix typo in http-push.c","startedAt":"2005-11-29T00:51:54Z","lastAt":"2005-11-29T16:40:02Z","messageCount":6,"participants":["Jan Andres","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"12903","messageId":"20051129005154.GA3076@pitr.home.jan","threadId":"2703","inReplyTo":null,"subject":"[PATCH] Fix typo in http-push.c","fromName":"Jan Andres","fromEmail":"jandres@gmx.net","sentAt":"2005-11-29T00:51:54Z","receivedAt":"2005-11-29T00:51:54Z","isPatch":true,"sender":{"key":"jandres@gmx.net","avatar":null},"body":"Hi guys,\n\nPlease find below the patch for a typo in http-push.c (in the maint\nbranch), which caused git-http-push to segfault on my Linux i386 box.\n\nRegards,\nJan\n\n\ndiff --git a/http-push.c b/http-push.c\nindex 76c7886..ad78982 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -784,7 +784,7 @@ static void handle_new_lock_ctx(struct x\n \t\t\t\t\tstrtol(ctx->cdata + 7, NULL, 10);\n \t\t} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {\n \t\t\tif (!strncmp(ctx->cdata, \"opaquelocktoken:\", 16)) {\n-\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata - 15));\n+\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata) - 15);\n \t\t\t\tstrcpy(lock->token, ctx->cdata + 16);\n \t\t\t}\n \t\t}\n\n-- \nJan Andres <jandres@gmx.net>\n"},{"id":"12911","messageId":"7vbr04ng7h.fsf@assigned-by-dhcp.cox.net","threadId":"2703","inReplyTo":"20051129005154.GA3076@pitr.home.jan","subject":"Re: [PATCH] Fix typo in http-push.c","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-29T06:03:30Z","receivedAt":"2005-11-29T06:03:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan Andres <jandres@gmx.net> writes:\n\n> Please find below the patch for a typo in http-push.c (in the maint\n> branch), which caused git-http-push to segfault on my Linux i386 box.\n\nThanks.  Next time around please sign-off your patches (see\nDocumentation/SubmittingPatches).\n"},{"id":"12923","messageId":"Pine.LNX.4.63.0511290923390.16927@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2703","inReplyTo":"20051129005154.GA3076@pitr.home.jan","subject":"Re: [PATCH] Fix typo in http-push.c","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-29T08:24:47Z","receivedAt":"2005-11-29T08:24:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 29 Nov 2005, Jan Andres wrote:\n\n> -\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata - 15));\n> +\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata) - 15);\n>  \t\t\t\tstrcpy(lock->token, ctx->cdata + 16);\n\nWhy not\n\n+\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata + 16));\n\nCiao,\nDscho\n"},{"id":"12931","messageId":"20051129133537.GA490@pitr.home.jan","threadId":"2703","inReplyTo":"Pine.LNX.4.63.0511290923390.16927@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Fix typo in http-push.c","fromName":"Jan Andres","fromEmail":"jandres@gmx.net","sentAt":"2005-11-29T13:35:37Z","receivedAt":"2005-11-29T13:35:37Z","isPatch":true,"sender":{"key":"jandres@gmx.net","avatar":null},"body":"Hi,\n\nOn Tue, 29. Nov. 2005 at 09:24:47 +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 29 Nov 2005, Jan Andres wrote:\n> \n> > -\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata - 15));\n> > +\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata) - 15);\n> >  \t\t\t\tstrcpy(lock->token, ctx->cdata + 16);\n> \n> Why not\n> \n> +\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata + 16));\n\nLooks more efficient indeed, but wouldn't we have to use\n\n+\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata + 16) + 1);\n\nso as to account for the trailing NUL?\n\nRegards\n-- \nJan Andres <jandres@gmx.net>\n"},{"id":"12936","messageId":"20051129153046.GA9091@pitr.home.jan","threadId":"2703","inReplyTo":"20051129133537.GA490@pitr.home.jan","subject":"[PATCH] Fix typo in http-push.c, take two","fromName":"Jan Andres","fromEmail":"jandres@gmx.net","sentAt":"2005-11-29T15:30:46Z","receivedAt":"2005-11-29T15:30:46Z","isPatch":true,"sender":{"key":"jandres@gmx.net","avatar":null},"body":"Ok, so this is my final(?) proposal for the fix.\n\n---\n\nFix a bug in handle_new_lock_ctx()'s memory allocation which may cause\nsegfaults.\n\nSigned-off-by: Jan Andres <jandres@gmx.net>\n\n---\n\ndiff --git a/http-push.c b/http-push.c\nindex 76c7886..bbb5118 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -784,7 +784,8 @@ static void handle_new_lock_ctx(struct x\n \t\t\t\t\tstrtol(ctx->cdata + 7, NULL, 10);\n \t\t} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {\n \t\t\tif (!strncmp(ctx->cdata, \"opaquelocktoken:\", 16)) {\n-\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata - 15));\n+\t\t\t\tlock->token =\n+\t\t\t\t\txmalloc(strlen(ctx->cdata + 16) + 1);\n \t\t\t\tstrcpy(lock->token, ctx->cdata + 16);\n \t\t\t}\n \t\t}\n---\n0.99.9.GIT\n\n-- \nJan Andres <jandres@gmx.net>\n"},{"id":"12937","messageId":"Pine.LNX.4.63.0511291739090.12136@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2703","inReplyTo":"20051129133537.GA490@pitr.home.jan","subject":"Re: [PATCH] Fix typo in http-push.c","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-29T16:40:02Z","receivedAt":"2005-11-29T16:40:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 29 Nov 2005, Jan Andres wrote:\n\n> [...]\n>\n> +\t\t\t\tlock->token = xmalloc(strlen(ctx->cdata + 16) + 1);\n> \n> so as to account for the trailing NUL?\n\nOf course! That's why I wanted to write \"strlen(ctx->cdata + 15)\", but I \nfsck'ed up. Sorry.\n\nCiao,\nDscho\n"}]}