* [PATCH] Fix typo in http-push.c
@ 2005-11-29 0:51 Jan Andres
2005-11-29 6:03 ` Junio C Hamano
2005-11-29 8:24 ` Johannes Schindelin
0 siblings, 2 replies; 6+ messages in thread
From: Jan Andres @ 2005-11-29 0:51 UTC (permalink / raw)
To: git
Hi guys,
Please find below the patch for a typo in http-push.c (in the maint
branch), which caused git-http-push to segfault on my Linux i386 box.
Regards,
Jan
diff --git a/http-push.c b/http-push.c
index 76c7886..ad78982 100644
--- a/http-push.c
+++ b/http-push.c
@@ -784,7 +784,7 @@ static void handle_new_lock_ctx(struct x
strtol(ctx->cdata + 7, NULL, 10);
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
if (!strncmp(ctx->cdata, "opaquelocktoken:", 16)) {
- lock->token = xmalloc(strlen(ctx->cdata - 15));
+ lock->token = xmalloc(strlen(ctx->cdata) - 15);
strcpy(lock->token, ctx->cdata + 16);
}
}
--
Jan Andres <jandres@gmx.net>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] Fix typo in http-push.c
2005-11-29 0:51 [PATCH] Fix typo in http-push.c Jan Andres
@ 2005-11-29 6:03 ` Junio C Hamano
2005-11-29 8:24 ` Johannes Schindelin
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2005-11-29 6:03 UTC (permalink / raw)
To: Jan Andres; +Cc: git
Jan Andres <jandres@gmx.net> writes:
> Please find below the patch for a typo in http-push.c (in the maint
> branch), which caused git-http-push to segfault on my Linux i386 box.
Thanks. Next time around please sign-off your patches (see
Documentation/SubmittingPatches).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix typo in http-push.c
2005-11-29 0:51 [PATCH] Fix typo in http-push.c Jan Andres
2005-11-29 6:03 ` Junio C Hamano
@ 2005-11-29 8:24 ` Johannes Schindelin
2005-11-29 13:35 ` Jan Andres
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2005-11-29 8:24 UTC (permalink / raw)
To: Jan Andres; +Cc: git
Hi,
On Tue, 29 Nov 2005, Jan Andres wrote:
> - lock->token = xmalloc(strlen(ctx->cdata - 15));
> + lock->token = xmalloc(strlen(ctx->cdata) - 15);
> strcpy(lock->token, ctx->cdata + 16);
Why not
+ lock->token = xmalloc(strlen(ctx->cdata + 16));
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix typo in http-push.c
2005-11-29 8:24 ` Johannes Schindelin
@ 2005-11-29 13:35 ` Jan Andres
2005-11-29 15:30 ` [PATCH] Fix typo in http-push.c, take two Jan Andres
2005-11-29 16:40 ` [PATCH] Fix typo in http-push.c Johannes Schindelin
0 siblings, 2 replies; 6+ messages in thread
From: Jan Andres @ 2005-11-29 13:35 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Hi,
On Tue, 29. Nov. 2005 at 09:24:47 +0100, Johannes Schindelin wrote:
> Hi,
>
> On Tue, 29 Nov 2005, Jan Andres wrote:
>
> > - lock->token = xmalloc(strlen(ctx->cdata - 15));
> > + lock->token = xmalloc(strlen(ctx->cdata) - 15);
> > strcpy(lock->token, ctx->cdata + 16);
>
> Why not
>
> + lock->token = xmalloc(strlen(ctx->cdata + 16));
Looks more efficient indeed, but wouldn't we have to use
+ lock->token = xmalloc(strlen(ctx->cdata + 16) + 1);
so as to account for the trailing NUL?
Regards
--
Jan Andres <jandres@gmx.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Fix typo in http-push.c, take two
2005-11-29 13:35 ` Jan Andres
@ 2005-11-29 15:30 ` Jan Andres
2005-11-29 16:40 ` [PATCH] Fix typo in http-push.c Johannes Schindelin
1 sibling, 0 replies; 6+ messages in thread
From: Jan Andres @ 2005-11-29 15:30 UTC (permalink / raw)
To: git
Ok, so this is my final(?) proposal for the fix.
---
Fix a bug in handle_new_lock_ctx()'s memory allocation which may cause
segfaults.
Signed-off-by: Jan Andres <jandres@gmx.net>
---
diff --git a/http-push.c b/http-push.c
index 76c7886..bbb5118 100644
--- a/http-push.c
+++ b/http-push.c
@@ -784,7 +784,8 @@ static void handle_new_lock_ctx(struct x
strtol(ctx->cdata + 7, NULL, 10);
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
if (!strncmp(ctx->cdata, "opaquelocktoken:", 16)) {
- lock->token = xmalloc(strlen(ctx->cdata - 15));
+ lock->token =
+ xmalloc(strlen(ctx->cdata + 16) + 1);
strcpy(lock->token, ctx->cdata + 16);
}
}
---
0.99.9.GIT
--
Jan Andres <jandres@gmx.net>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] Fix typo in http-push.c
2005-11-29 13:35 ` Jan Andres
2005-11-29 15:30 ` [PATCH] Fix typo in http-push.c, take two Jan Andres
@ 2005-11-29 16:40 ` Johannes Schindelin
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2005-11-29 16:40 UTC (permalink / raw)
To: Jan Andres; +Cc: git
Hi,
On Tue, 29 Nov 2005, Jan Andres wrote:
> [...]
>
> + lock->token = xmalloc(strlen(ctx->cdata + 16) + 1);
>
> so as to account for the trailing NUL?
Of course! That's why I wanted to write "strlen(ctx->cdata + 15)", but I
fsck'ed up. Sorry.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-11-29 16:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-29 0:51 [PATCH] Fix typo in http-push.c Jan Andres
2005-11-29 6:03 ` Junio C Hamano
2005-11-29 8:24 ` Johannes Schindelin
2005-11-29 13:35 ` Jan Andres
2005-11-29 15:30 ` [PATCH] Fix typo in http-push.c, take two Jan Andres
2005-11-29 16:40 ` [PATCH] Fix typo in http-push.c Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox