threads / patch / 21851

patchbuiltin-push: don't access freed transport->url

Subject: [PATCH] builtin-push: don't access freed transport->url

## tl;dr

3 messages between Dec 3, 2009 and Dec 4, 2009. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Tay Ray Chuan· Dec 3, 2009, 23:31 UTC · lore

Move the failed push message to before transport_disconnect() so that it doesn't access transport->url after transport has been free()'d (in transport_disconnect()).

Additionally, make the failed push message more accurate by moving it before transport_disconnect(), so that it doesn't report errors due to a failed disconnect.

Cc: "Daniel Barkalow" <barkalow@iabervon.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 builtin-push.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Show changes to builtin-push.c +3 −3
diff --git a/builtin-push.c b/builtin-push.c
index a21e46c..dcfb53f 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)
 		fprintf(stderr, "Pushing to %s\n", transport->url);
 	err = transport_push(transport, refspec_nr, refspec, flags,
 			     &nonfastforward);
+	if (err != 0)
+		error("failed to push some refs to '%s'", transport->url);
+
 	err |= transport_disconnect(transport);

 	if (!err)
 		return 0;

-	error("failed to push some refs to '%s'", transport->url);
-
 	if (nonfastforward && advice_push_nonfastforward) {
 		printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
 		       "Merge the remote changes before pushing again.  See the 'non-fast-forward'\n"
--
1.6.6.rc1.249.g048b3
Daniel Barkalow· Dec 3, 2009, 23:38 UTC · re: Tay Ray Chuan · lore

Re: [PATCH] builtin-push: don't access freed transport->url

On Fri, 4 Dec 2009, Tay Ray Chuan wrote:
Show 10 quoted lines
> Move the failed push message to before transport_disconnect() so that
> it doesn't access transport->url after transport has been free()'d (in
> transport_disconnect()).
> 
> Additionally, make the failed push message more accurate by moving it
> before transport_disconnect(), so that it doesn't report errors due
> to a failed disconnect.
> 
> Cc: "Daniel Barkalow" <barkalow@iabervon.org>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Show 28 quoted lines
> ---
>  builtin-push.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin-push.c b/builtin-push.c
> index a21e46c..dcfb53f 100644
> --- a/builtin-push.c
> +++ b/builtin-push.c
> @@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)
>  		fprintf(stderr, "Pushing to %s\n", transport->url);
>  	err = transport_push(transport, refspec_nr, refspec, flags,
>  			     &nonfastforward);
> +	if (err != 0)
> +		error("failed to push some refs to '%s'", transport->url);
> +
>  	err |= transport_disconnect(transport);
> 
>  	if (!err)
>  		return 0;
> 
> -	error("failed to push some refs to '%s'", transport->url);
> -
>  	if (nonfastforward && advice_push_nonfastforward) {
>  		printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
>  		       "Merge the remote changes before pushing again.  See the 'non-fast-forward'\n"
> --
> 1.6.6.rc1.249.g048b3
> 

← back to recent threads