mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-11 13:25:34 +00:00
Add version of MBEDTLS_X509_SAFE_SNPRINTF supporting cleanup section
This will be needed in debugging functions that maintain heap allocated state, and which hence needs to be freed in case an `snprintf()` call fails.
This commit is contained in:
parent
45eedf1ace
commit
343fec08ad
|
@ -355,6 +355,18 @@ int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start,
|
|||
p += (size_t) ret; \
|
||||
} while( 0 )
|
||||
|
||||
#define MBEDTLS_X509_SAFE_SNPRINTF_WITH_CLEANUP \
|
||||
do { \
|
||||
if( ret < 0 || (size_t) ret >= n ) \
|
||||
{ \
|
||||
ret = MBEDTLS_ERR_X509_BUFFER_TOO_SMALL; \
|
||||
goto cleanup; \
|
||||
} \
|
||||
\
|
||||
n -= (size_t) ret; \
|
||||
p += (size_t) ret; \
|
||||
} while( 0 )
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue