mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
mbedtls: only free crt_parse when something came back
Mbedtls mbedtls_x509_crt_parse() returns 0 for success which is good. But it has a complicated idea about what to return on fail... if it couldn't make even one cert from the data, then it returns a negative return indicating the parsing problem and there is nothing to free. If it managed to parse at least one cert, instead it retuns a positive number indicating the number of certs it didn't parse successfully, and there is something to free. Adapt the code to understand this quirk.
This commit is contained in:
parent
05fdf38750
commit
ec9e8ab892
2 changed files with 3 additions and 2 deletions
|
@ -327,7 +327,7 @@ set(PACKAGE "libwebsockets")
|
|||
set(CPACK_PACKAGE_NAME "${PACKAGE}")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "4")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "19")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "20")
|
||||
set(CPACK_PACKAGE_RELEASE 1)
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
|
|
|
@ -240,7 +240,8 @@ lws_x509_parse_from_pem(struct lws_x509_cert *x509, const void *pem, size_t len)
|
|||
|
||||
ret = mbedtls_x509_crt_parse(&x509->cert, pem, len);
|
||||
if (ret) {
|
||||
mbedtls_x509_crt_free(&x509->cert);
|
||||
if (ret > 0)
|
||||
mbedtls_x509_crt_free(&x509->cert);
|
||||
lwsl_err("%s: unable to parse PEM cert: -0x%x\n",
|
||||
__func__, -ret);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue