File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10880,7 +10880,7 @@ const char* wolfSSL_OpenSSL_version(int type)
1088010880 case OPENSSL_ENGINES_DIR:
1088110881 return "ENGINESDIR: N/A";
1088210882 default:
10883- return "wolfSSL " LIBWOLFSSL_VERSION_STRING ;
10883+ return "not available" ;
1088410884 }
1088510885}
1088610886#else
Original file line number Diff line number Diff line change @@ -2284,21 +2284,33 @@ int wolfSSL_i2d_PUBKEY_bio(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key)
22842284 int ret = WC_NO_ERR_TRACE (WOLFSSL_FAILURE );
22852285 int derSz = 0 ;
22862286 byte * der = NULL ;
2287+ byte * derPtr = NULL ;
22872288
22882289 WOLFSSL_ENTER ("wolfSSL_i2d_PUBKEY_bio" );
22892290
22902291 if (bio == NULL || key == NULL ) {
22912292 return WOLFSSL_FAILURE ;
22922293 }
22932294
2294- /* Let wolfSSL_i2d_PUBKEY allocate the buffer (pass NULL to trigger
2295- * internal allocation). We free it ourselves after writing to the BIO. */
2296- derSz = wolfSSL_i2d_PUBKEY (key , & der );
2297- if (derSz <= 0 || der == NULL ) {
2298- WOLFSSL_MSG ("wolfSSL_i2d_PUBKEY failed" );
2295+ derSz = wolfSSL_i2d_PUBKEY (key , NULL );
2296+ if (derSz <= 0 ) {
2297+ WOLFSSL_MSG ("wolfSSL_i2d_PUBKEY size query failed" );
2298+ return WOLFSSL_FAILURE ;
2299+ }
2300+
2301+ der = (byte * )XMALLOC ((size_t )derSz , NULL , DYNAMIC_TYPE_TMP_BUFFER );
2302+ if (der == NULL ) {
2303+ WOLFSSL_MSG ("XMALLOC failed" );
22992304 return WOLFSSL_FAILURE ;
23002305 }
23012306
2307+ derPtr = der ;
2308+ derSz = wolfSSL_i2d_PUBKEY (key , & derPtr );
2309+ if (derSz <= 0 ) {
2310+ WOLFSSL_MSG ("wolfSSL_i2d_PUBKEY failed" );
2311+ goto cleanup ;
2312+ }
2313+
23022314 if (wolfSSL_BIO_write (bio , der , derSz ) != derSz ) {
23032315 goto cleanup ;
23042316 }
You can’t perform that action at this time.
0 commit comments