diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2013-06-28 10:58:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-08-12 21:14:11 +0200 |
commit | 86e309fcb5ba64d29821b1e40407a4007e34df75 (patch) | |
tree | 16a7a9bee74cefb9916dbe229f492dc23cf28f3d | |
parent | 1a194aa2c79aa9514b4a2a302b05ba641811fc9f (diff) | |
download | cgit-86e309fcb5ba64d29821b1e40407a4007e34df75.tar.gz cgit-86e309fcb5ba64d29821b1e40407a4007e34df75.tar.xz |
Fix section-from-path > 1
When having found the first path separator occurrence at position i, we
invoked strchr() on the same position i in subsequent iterations
resulting in the same path separator being returned by strchr() over and
over again. Increase the position by one to skip the occurrence that has
just been found and advance to the next separator.
Reported-by: Konstantin Ryabitsev <mricon@kernel.org>
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
-rw-r--r-- | scan-tree.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/scan-tree.c b/scan-tree.c index 2684b44..7cd8f08 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -148,14 +148,14 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) } if (ctx.cfg.section_from_path) { - n = ctx.cfg.section_from_path; + n = ctx.cfg.section_from_path; if (n > 0) { - slash = rel.buf; - while (slash && n && (slash = strchr(slash, '/'))) + slash = rel.buf - 1; + while (slash && n && (slash = strchr(slash + 1, '/'))) n--; } else { slash = rel.buf + rel.len; - while (slash && n && (slash = xstrrchr(rel.buf, slash, '/'))) + while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/'))) n++; } if (slash && !n) { |