Skip to content

Commit 68c14c2

Browse files
jayatheerthkulkarnigitster
authored andcommitted
path: use the right datatype
The strlen() function returns a size_t Storing this in a standard signed int is a bad practice that invites overflow vulnerabilities if paths get absurdly long. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 21a5f4e commit 68c14c2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)
5858

5959
static int dir_prefix(const char *buf, const char *dir)
6060
{
61-
int len = strlen(dir);
61+
size_t len = strlen(dir);
6262
return !strncmp(buf, dir, len) &&
6363
(is_dir_sep(buf[len]) || buf[len] == '\0');
6464
}

0 commit comments

Comments
 (0)