Skip to content

Commit 39a7fe3

Browse files
committed
Fixed off-by-one buffer issue in uv_exepath()
1 parent 91ee8f4 commit 39a7fe3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

php_uv.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,13 +4951,13 @@ PHP_FUNCTION(uv_hrtime)
49514951
*/
49524952
PHP_FUNCTION(uv_exepath)
49534953
{
4954-
char buffer[1024] = {0};
4955-
size_t buffer_sz;
4956-
4957-
buffer_sz = sizeof(buffer);
4958-
uv_exepath(buffer, &buffer_sz);
4959-
buffer[buffer_sz] = '\0';
4960-
4954+
char buffer[MAXPATHLEN];
4955+
size_t buffer_sz = sizeof(buffer) / sizeof(buffer[0]);
4956+
4957+
if (uv_exepath(buffer, &buffer_sz) == UV_EINVAL) {
4958+
RETURN_FALSE;
4959+
}
4960+
49614961
RETURN_STRINGL(buffer, buffer_sz, 1);
49624962
}
49634963
/* }}} */

0 commit comments

Comments
 (0)