mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-25 23:21:06 +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; \
|
p += (size_t) ret; \
|
||||||
} while( 0 )
|
} 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue