From 382148d7bb0faca5cd7f4e009358095bd448bb23 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 26 Feb 2023 14:06:30 +0000 Subject: [PATCH] Fix UBSAN warning about applying zero offset to null pointer (#10700) vpath may be NULL here so check for it before trying to add 0 (the length of the vpath) to it. --- sapi/cli/php_cli_server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 4d218000d0d9a..e59037ac2e8d3 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -1785,8 +1785,10 @@ static int php_cli_server_client_read_request_on_message_complete(php_http_parse php_cli_server_client *client = parser->data; client->request.protocol_version = parser->http_major * 100 + parser->http_minor; php_cli_server_request_translate_vpath(&client->request, client->server->document_root, client->server->document_root_len); - { - const char *vpath = client->request.vpath, *end = vpath + client->request.vpath_len, *p = end; + if (client->request.vpath) { + const char *vpath = client->request.vpath; + const char *end = vpath + client->request.vpath_len; + const char *p = end; client->request.ext = end; client->request.ext_len = 0; while (p > vpath) {