summaryrefslogtreecommitdiff
path: root/tests/pkcs11
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2019-01-29 16:10:59 +0100
committerTim Rühsen <tim.ruehsen@gmx.de>2019-02-14 10:29:25 +0100
commit95dd4be4e7461dd07cc64c6ae5aaa8d5cc553935 (patch)
tree0ff477d2d24e7e29a4d64cab9eb85f5827f857df /tests/pkcs11
parent1b8703fb1a748a973f6c7c60269632218ab77596 (diff)
downloadgnutls-95dd4be4e7461dd07cc64c6ae5aaa8d5cc553935.tar.gz
Fix uninitialized warning in pkcs11.c
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
Diffstat (limited to 'tests/pkcs11')
-rw-r--r--tests/pkcs11/pkcs11-token-raw.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/pkcs11/pkcs11-token-raw.c b/tests/pkcs11/pkcs11-token-raw.c
index bbcb23eb81..605c96ce1d 100644
--- a/tests/pkcs11/pkcs11-token-raw.c
+++ b/tests/pkcs11/pkcs11-token-raw.c
@@ -93,6 +93,36 @@ void doit(void)
exit(1);
}
+ {
+ static const char url[] = "pkcs11:token=whatever";
+
+ /* Testing a too small buffer */
+ size_t size = 1;
+ char *buf = gnutls_malloc(size);
+ ret = gnutls_pkcs11_token_get_info(url,
+ GNUTLS_PKCS11_TOKEN_LABEL,
+ buf, &size);
+ assert(ret == GNUTLS_E_SHORT_MEMORY_BUFFER);
+
+ /* Testing a too small buffer by one */
+ size -= 1;
+ buf = gnutls_realloc(buf, size);
+ ret = gnutls_pkcs11_token_get_info(url,
+ GNUTLS_PKCS11_TOKEN_LABEL,
+ buf, &size);
+ assert(ret == GNUTLS_E_SHORT_MEMORY_BUFFER);
+
+ /* Testing an exactly fitting buffer */
+ buf = gnutls_realloc(buf, size);
+ ret = gnutls_pkcs11_token_get_info(url,
+ GNUTLS_PKCS11_TOKEN_LABEL,
+ buf, &size);
+ assert(ret == 0);
+ assert(strcmp(buf, "whatever") == 0);
+
+ gnutls_free(buf);
+ }
+
ret = gnutls_pkcs11_token_get_ptr("pkcs11:token=invalid", (void**)&mod, &slot_id, 0);
assert(ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);