]> git.ipfire.org Git - thirdparty/git.git/commit
path: use size_t for dir_prefix length
authorK Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Wed, 4 Mar 2026 13:05:01 +0000 (18:35 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Mar 2026 17:06:30 +0000 (09:06 -0800)
commit61d0b79e4c2dffa27c89b409aaa084deb0ed2172
tree3914c735dc01181175e8fd8b66f96e32c7ed4d74
parent99a626f479781da77ea41f356bd35a27af8ec11b
path: use size_t for dir_prefix length

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.

Switch the variable to size_t. This is safe to do because 'len' is
strictly used as an argument to strncmp() (which expects size_t) and
as a positive array index, involving no signed arithmetic that could
rely on negative values.

Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c