Skip to content

Commit

Permalink
Off-by-one error in get_path_prefix(), found by Valgrind
Browse files Browse the repository at this point in the history
[jc: original fix was done by Pavel and this contains improvements
 by Rene.]

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Acked-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Rene Scharfe authored and Junio C Hamano committed Jun 7, 2006
1 parent 7fb23e6 commit 17cf250
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-tar-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ static int get_path_prefix(const struct strbuf *path, int maxlen)
int i = path->len;
if (i > maxlen)
i = maxlen;
while (i > 0 && path->buf[i] != '/')
do {
i--;
} while (i > 0 && path->buf[i] != '/');
return i;
}

Expand Down

0 comments on commit 17cf250

Please sign in to comment.