Skip to content

Commit 1518c3d

Browse files
committed
Moved from dynamic string to static string buffer for simplicity.
1 parent 8c8274a commit 1518c3d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

sslscan.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,12 +5698,9 @@ int testSupportedGroups(struct sslCheckOptions *options) {
56985698
if (tls_version != TLSv1_3)
56995699
continue;
57005700

5701-
/* Copy the group name, since we'll be modifying it.*/
5702-
char *my_group_name = strdup(group_name);
5703-
if (my_group_name == NULL) {
5704-
fprintf(stderr, "strdup2 failed.\n");
5705-
continue;
5706-
}
5701+
/* Copy the group name since we will be modifying it. */
5702+
char my_group_name[32] = {0};
5703+
strncpy(my_group_name, group_name, sizeof(my_group_name) - 1);
57075704

57085705
/* Strip the trailing "tls13" string from "brainpoolP256r1tls13". */
57095706
if (strlen(my_group_name) >= 16)
@@ -5713,7 +5710,6 @@ int testSupportedGroups(struct sslCheckOptions *options) {
57135710
EVP_PKEY *key = EVP_EC_gen(my_group_name);
57145711
if (key == NULL) {
57155712
fprintf(stderr, "Failed to generate %s key.\n", my_group_name);
5716-
free(my_group_name); my_group_name = NULL;
57175713
continue;
57185714
}
57195715

@@ -5722,14 +5718,12 @@ int testSupportedGroups(struct sslCheckOptions *options) {
57225718
size_t pubkey_bytes_len = EVP_PKEY_get1_encoded_public_key(key, &pubkey_bytes);
57235719
if ((pubkey_bytes == NULL) || (pubkey_bytes_len <= 0)) {
57245720
fprintf(stderr, "Failed to get public key bytes for %s key.\n", my_group_name);
5725-
free(my_group_name); my_group_name = NULL;
57265721
EVP_PKEY_free(key); key = NULL;
57275722
continue;
57285723
}
57295724

57305725
bs_append_bytes(key_exchange, pubkey_bytes, pubkey_bytes_len);
57315726

5732-
free(my_group_name); my_group_name = NULL;
57335727
OPENSSL_free(pubkey_bytes); pubkey_bytes = NULL;
57345728
EVP_PKEY_free(key); key = NULL;
57355729

0 commit comments

Comments
 (0)