Skip to content

Commit 5fffdaa

Browse files
committed
openssl: change uses of sprintf into snprintf and zend_string_concat2
1 parent 429f91d commit 5fffdaa

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

ext/openssl/openssl.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,9 +1641,7 @@ PHP_FUNCTION(openssl_spki_new)
16411641
goto cleanup;
16421642
}
16431643

1644-
s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0);
1645-
sprintf(ZSTR_VAL(s), "%s%s", spkac, spkstr);
1646-
ZSTR_LEN(s) = strlen(ZSTR_VAL(s));
1644+
s = zend_string_concat2(spkac, strlen(spkac), spkstr, strlen(spkstr));
16471645
OPENSSL_free(spkstr);
16481646

16491647
RETVAL_STR(s);

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
498498
OPENSSL_free(cert_name);
499499
} else if (san->type == GEN_IPADD) {
500500
if (san->d.iPAddress->length == 4) {
501-
sprintf(ipbuffer, "%d.%d.%d.%d",
501+
snprintf(ipbuffer, sizeof(ipbuffer), "%d.%d.%d.%d",
502502
san->d.iPAddress->data[0],
503503
san->d.iPAddress->data[1],
504504
san->d.iPAddress->data[2],

0 commit comments

Comments
 (0)