Skip to content

Commit c810844

Browse files
committed
Fix potential OOB when checking for trailing spaces
If `path_len` is zero, we must not access `path`, let alone try to subtract `-1` from it. Since `path` and `path_len` are supposed to come from a `zend_string`, this is not a security issue.
1 parent a6a290d commit c810844

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

win32/winutil.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int php_win32_check_trailing_space(const char * path, const size_t path_len)
5959
if (path_len > MAXPATHLEN - 1) {
6060
return 1;
6161
}
62-
if (path) {
62+
if (path && path_len > 0) {
6363
if (path[0] == ' ' || path[path_len - 1] == ' ') {
6464
return 0;
6565
} else {

0 commit comments

Comments
 (0)