Fix typo in http-push.c
PATCH 1/1 Fix typo in http-push.c
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
http-push.c +1 -1
@@ -784,7 +784,7 @@ static void handle_new_lock_ctx(struct xstrtol (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 ); } }
Signature · 1 line
Jan Andres <[email protected]>
Quoted 2 lines · Jan Andres
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).
Hi,
http-push.c static void handle_new_lock_ctx(struct x · line 788
Quoted 3 lines · Jan Andres
http-push.c +1
-1- 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
Hi,
Review
Quoted 11 lines · Johannes Schindelin
Hi,
http-push.c static void handle_new_lock_ctx(struct x · line 788
Quoted 3 lines · Jan Andres
http-push.c +1
-1- lock->token =xmalloc (strlen (ctx->cdata -15 )); + lock->token =xmalloc (strlen (ctx->cdata) -15 );strcpy (lock->token, ctx->cdata +16 );Why not
(quoted diff) +1
-0+ 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
Signature · 1 line
Jan Andres <[email protected]>
PATCH 1/1 Fix typo in http-push.c, take two
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.
---
http-push.c +2 -1
@@ -784,7 +784,8 @@ static void handle_new_lock_ctx(struct xstrtol (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
Signature · 1 line
Jan Andres <[email protected]>
Hi,
Quoted 5 lines · Jan Andres
[...]
(quoted diff) +1
-0+ 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