Skip to content

Commit 667f35d

Browse files
committed
ext/soap: replace strcat/strncpy with memcpy for pre-allocated buffers.
1 parent 13b83a4 commit 667f35d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

ext/soap/php_http.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,17 +1169,16 @@ int make_http_soap_request(
11691169
char *p = strrchr(t, '/');
11701170
if (p) {
11711171
zend_string *s = zend_string_alloc((p - t) + ZSTR_LEN(new_uri->path) + 2, 0);
1172-
strncpy(ZSTR_VAL(s), t, (p - t) + 1);
1173-
ZSTR_VAL(s)[(p - t) + 1] = 0;
1174-
strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path));
1172+
memcpy(ZSTR_VAL(s), t, (p - t) + 1);
1173+
memcpy(ZSTR_VAL(s) + (p - t) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1);
11751174
zend_string_release_ex(new_uri->path, 0);
11761175
new_uri->path = s;
11771176
}
11781177
} else {
11791178
zend_string *s = zend_string_alloc(ZSTR_LEN(new_uri->path) + 2, 0);
11801179
ZSTR_VAL(s)[0] = '/';
11811180
ZSTR_VAL(s)[1] = 0;
1182-
strcat(ZSTR_VAL(s), ZSTR_VAL(new_uri->path));
1181+
memcpy(ZSTR_VAL(s) + 1, ZSTR_VAL(new_uri->path), ZSTR_LEN(new_uri->path) + 1);
11831182
zend_string_release_ex(new_uri->path, 0);
11841183
new_uri->path = s;
11851184
}

0 commit comments

Comments
 (0)