aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorViktor Dukhovni <openssl-users@dukhovni.org>2018-12-09 18:37:56 -0500
committerViktor Dukhovni <openssl-users@dukhovni.org>2018-12-09 22:02:48 -0500
commit1057c2c39f5df45c36c0fc4d78dc9d3b91f78bc6 (patch)
tree0e20cb671cd05d2574c9134721faf47efbb9bf3a /test
parent9b340281873643d2b8a33047dc8bfa607f7e0c3c (diff)
downloadopenssl-1057c2c39f5df45c36c0fc4d78dc9d3b91f78bc6.tar.gz
Cleaner disposal of ephemeral engine ids and names
Engine names and ids are typically static strings. If an application actually dynamically allocated these, the application owns the storage, and should dispose of it via the original handle, rather than the "const char *" returned by the engine. In any case, this resolves the test code issue without resort to "unconst" macros/casts. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'test')
-rw-r--r--test/enginetest.c15
-rw-r--r--test/hmactest.c4
2 files changed, 10 insertions, 9 deletions
diff --git a/test/enginetest.c b/test/enginetest.c
index dfd5c3f28b..4836cbe92f 100644
--- a/test/enginetest.c
+++ b/test/enginetest.c
@@ -44,8 +44,9 @@ static void display_engine_list(void)
static int test_engines(void)
{
ENGINE *block[NUMTOADD];
+ char *eid[NUMTOADD];
+ char *ename[NUMTOADD];
char buf[256];
- const char *id, *name;
ENGINE *ptr;
int loop;
int to_return = 0;
@@ -138,12 +139,12 @@ static int test_engines(void)
TEST_info("About to beef up the engine-type list");
for (loop = 0; loop < NUMTOADD; loop++) {
sprintf(buf, "id%d", loop);
- id = OPENSSL_strdup(buf);
+ eid[loop] = OPENSSL_strdup(buf);
sprintf(buf, "Fake engine type %d", loop);
- name = OPENSSL_strdup(buf);
+ ename[loop] = OPENSSL_strdup(buf);
if (!TEST_ptr(block[loop] = ENGINE_new())
- || !TEST_true(ENGINE_set_id(block[loop], id))
- || !TEST_true(ENGINE_set_name(block[loop], name)))
+ || !TEST_true(ENGINE_set_id(block[loop], eid[loop]))
+ || !TEST_true(ENGINE_set_name(block[loop], ename[loop])))
goto end;
}
for (loop = 0; loop < NUMTOADD; loop++) {
@@ -162,8 +163,8 @@ static int test_engines(void)
ENGINE_free(ptr);
}
for (loop = 0; loop < NUMTOADD; loop++) {
- OPENSSL_free((void *)(intptr_t)ENGINE_get_id(block[loop]));
- OPENSSL_free((void *)(intptr_t)ENGINE_get_name(block[loop]));
+ OPENSSL_free(eid[loop]);
+ OPENSSL_free(ename[loop]);
}
to_return = 1;
diff --git a/test/hmactest.c b/test/hmactest.c
index 529670c2c9..893e6169b4 100644
--- a/test/hmactest.c
+++ b/test/hmactest.c
@@ -38,7 +38,7 @@ static struct test_st {
"e9139d1e6ee064ef8cf514fc7dc83e86",
},
{
- "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
+ "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
16, "Hi There", 8,
"9294727a3638bb1c13f48ef8158bfc9d",
},
@@ -47,7 +47,7 @@ static struct test_st {
"750c783e6ab0b503eaa86e310a5db738",
},
{
- "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
+ "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
16, {
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,