Memory allocation failures could have resulted in error paths that
dereference a NULL pointer or double-freeing memory. Fix this by
explicitly clearing the freed pointer and checking allocation results.
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
base64 = base64_encode(der, der_len, &len);
OPENSSL_free(der);
+ der = NULL;
if (!base64)
goto fail;
pos = (char *) base64;
x = (char *) base64_url_encode(pos, curve->prime_len, NULL, 0);
pos += curve->prime_len;
y = (char *) base64_url_encode(pos, curve->prime_len, NULL, 0);
+ if (!x || !y)
+ goto fail;
wpabuf_put_str(buf, "\"");
wpabuf_put_str(buf, name);
}
wpabuf_put_str(buf, "\"}");
ret = 0;
-out:
+fail:
wpabuf_free(pub);
os_free(x);
os_free(y);
return ret;
-fail:
- goto out;
}