Add check for the return value of gnutls_malloc() and gnutls_strdup() to avoid potential NULL pointer dereference.
Fixes: 44541d17 ("p11tool: copy vendor query attributes when listing privkeys")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
if (vendor) {
objurl = gnutls_malloc(strlen(output) + strlen(vendor) +
1);
+ if (objurl == NULL) {
+ fprintf(stderr, "memory error\n");
+ gnutls_free(output);
+ app_exit(1);
+ }
+
strcpy(objurl, output);
strcat(objurl, vendor);
} else {
objurl = gnutls_strdup(output);
+ if (objurl == NULL) {
+ fprintf(stderr, "memory error\n");
+ gnutls_free(output);
+ app_exit(1);
+ }
}
p = NULL;