All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] setup.c: Fix prefix_pathspec from looping pass end of string
@ 2013-03-07 16:36 Andrew Wong
  2013-03-07 21:48 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Wong @ 2013-03-07 16:36 UTC (permalink / raw)
  To: git; +Cc: Andrew Wong

The previous code was assuming length ends at either `)` or `,`, and was
not handling the case where strcspn returns length due to end of string.
So specifying ":(top" as pathspec will cause the loop to go pass the end
of string.

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
---
 setup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index 1dee47e..f4c4e73 100644
--- a/setup.c
+++ b/setup.c
@@ -207,9 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char
 		     *copyfrom && *copyfrom != ')';
 		     copyfrom = nextat) {
 			size_t len = strcspn(copyfrom, ",)");
-			if (copyfrom[len] == ')')
+			if (copyfrom[len] == '\0')
 				nextat = copyfrom + len;
-			else
+			else if (copyfrom[len] == ')')
+				nextat = copyfrom + len;
+			else if (copyfrom[len] == ',')
 				nextat = copyfrom + len + 1;
 			if (!len)
 				continue;
-- 
1.8.2.rc0.22.gb3600c3

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

end of thread, other threads:[~2013-03-09 23:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07 16:36 [PATCH] setup.c: Fix prefix_pathspec from looping pass end of string Andrew Wong
2013-03-07 21:48 ` Junio C Hamano
2013-03-07 22:25   ` Andrew Wong
2013-03-07 23:59     ` Junio C Hamano
2013-03-08  0:25       ` Andrew Wong
2013-03-08  1:51         ` Junio C Hamano
2013-03-08  1:58           ` Andrew Wong
2013-03-09 23:45           ` [PATCH 1/2] " Andrew Wong
2013-03-09 23:46             ` [PATCH 2/2] setup.c: Check that the pathspec magic ends with ")" Andrew Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.