git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz()
@ 2014-12-24  0:18 René Scharfe
  2014-12-24  2:08 ` Jonathan Nieder
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2014-12-24  0:18 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 transport.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/transport.c b/transport.c
index 70d38e4..08bcd3a 100644
--- a/transport.c
+++ b/transport.c
@@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	} else {
 		/* Unknown protocol in URL. Pass to external handler. */
 		int len = external_specification_len(url);
-		char *handler = xmalloc(len + 1);
-		handler[len] = 0;
-		strncpy(handler, url, len);
+		char *handler = xmemdupz(url, len);
 		transport_helper_init(ret, handler);
 	}
 
-- 
2.2.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz()
  2014-12-24  0:18 [PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz() René Scharfe
@ 2014-12-24  2:08 ` Jonathan Nieder
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Nieder @ 2014-12-24  2:08 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano

René Scharfe wrote:

> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
>  transport.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Since external_specification_len(url) is defined to always be less than
strlen(url) when is_url(url), this should be safe.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-24  2:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-24  0:18 [PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz() René Scharfe
2014-12-24  2:08 ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).