From 667f35dbc88ba692f2af659392c457bf36efa12e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 11 Mar 2026 22:06:04 +0000 Subject: [PATCH 1/3] ext/soap: replace strcat/strncpy with memcpy for pre-allocated buffers. --- ext/soap/php_http.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 4bf599234f78..6b08ed080950 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1169,9 +1169,8 @@ int make_http_soap_request( char *p = strrchr(t, '/'); if (p) { zend_string *s = zend_string_alloc((p - t) + ZSTR_LEN(new_uri->path) + 2, 0); - strncpy(ZSTR_VAL(s), t, (p - t) + 1); - ZSTR_VAL(s)[(p - t) + 1] = 0; - strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path)); + memcpy(ZSTR_VAL(s), t, (p - t) + 1); + memcpy(ZSTR_VAL(s) + (p - t) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1); zend_string_release_ex(new_uri->path, 0); new_uri->path = s; } @@ -1179,7 +1178,7 @@ int make_http_soap_request( zend_string *s = zend_string_alloc(ZSTR_LEN(new_uri->path) + 2, 0); ZSTR_VAL(s)[0] = '/'; ZSTR_VAL(s)[1] = 0; - strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path)); + memcpy(ZSTR_VAL(s) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1); zend_string_release_ex(new_uri->path, 0); new_uri->path = s; } From 14791ce1e9a943b155fb98abaf050a6be575fdd4 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 11 Mar 2026 22:06:11 +0000 Subject: [PATCH 2/3] remove redundant memset before struct copy. --- ext/soap/php_sdl.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index e6871cd6e9b3..ad37867dd460 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -2433,7 +2433,6 @@ static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashT ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(headers, key, tmp) { pheader = malloc(sizeof(sdlSoapBindingFunctionHeader)); - memset(pheader, 0, sizeof(sdlSoapBindingFunctionHeader)); *pheader = *tmp; if (pheader->name) { @@ -2497,7 +2496,6 @@ static HashTable* make_persistent_sdl_parameters(HashTable *params, HashTable *p ZEND_HASH_FOREACH_STR_KEY_PTR(params, key, tmp) { pparam = malloc(sizeof(sdlParam)); - memset(pparam, 0, sizeof(sdlParam)); *pparam = *tmp; if (pparam->paramName) { @@ -2539,7 +2537,6 @@ static HashTable* make_persistent_sdl_function_faults(sdlFunctionPtr func, HashT ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(faults, key, tmp) { pfault = malloc(sizeof(sdlFault)); - memset(pfault, 0, sizeof(sdlFault)); *pfault = *tmp; if (pfault->name) { From 8dfe6bcf8a5ed2774ea3450e29f640d2f76efd61 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 12 Mar 2026 07:48:46 +0000 Subject: [PATCH 3/3] feedback --- ext/soap/php_http.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 6b08ed080950..bac21d26b358 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1168,17 +1168,12 @@ int make_http_soap_request( char *t = ZSTR_VAL(new_uri->path); char *p = strrchr(t, '/'); if (p) { - zend_string *s = zend_string_alloc((p - t) + ZSTR_LEN(new_uri->path) + 2, 0); - memcpy(ZSTR_VAL(s), t, (p - t) + 1); - memcpy(ZSTR_VAL(s) + (p - t) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1); + zend_string *s = zend_string_concat2(t, (p - t) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path)); zend_string_release_ex(new_uri->path, 0); new_uri->path = s; } } else { - zend_string *s = zend_string_alloc(ZSTR_LEN(new_uri->path) + 2, 0); - ZSTR_VAL(s)[0] = '/'; - ZSTR_VAL(s)[1] = 0; - memcpy(ZSTR_VAL(s) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1); + zend_string *s = zend_string_concat2("/", 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path)); zend_string_release_ex(new_uri->path, 0); new_uri->path = s; }