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>
This commit is contained in:
K Jayatheerth
2026-03-02 19:51:37 +05:30
committed by Junio C Hamano
parent 21a5f4ec11
commit 68c14c2a03

2
path.c
View File

@@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)
static int dir_prefix(const char *buf, const char *dir)
{
int len = strlen(dir);
size_t len = strlen(dir);
return !strncmp(buf, dir, len) &&
(is_dir_sep(buf[len]) || buf[len] == '\0');
}