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>
This commit is contained in:
parent
1a194aa2c7
commit
86e309fcb5
@ -150,12 +150,12 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
|
|||||||
if (ctx.cfg.section_from_path) {
|
if (ctx.cfg.section_from_path) {
|
||||||
n = ctx.cfg.section_from_path;
|
n = ctx.cfg.section_from_path;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
slash = rel.buf;
|
slash = rel.buf - 1;
|
||||||
while (slash && n && (slash = strchr(slash, '/')))
|
while (slash && n && (slash = strchr(slash + 1, '/')))
|
||||||
n--;
|
n--;
|
||||||
} else {
|
} else {
|
||||||
slash = rel.buf + rel.len;
|
slash = rel.buf + rel.len;
|
||||||
while (slash && n && (slash = xstrrchr(rel.buf, slash, '/')))
|
while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/')))
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
if (slash && !n) {
|
if (slash && !n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user