Rationalize snprintf() usage in X.509 modules

This commit is contained in:
Manuel Pégourié-Gonnard 2015-06-22 11:12:02 +02:00
parent 7b6dcbe993
commit 1685368408
6 changed files with 61 additions and 262 deletions

View file

@ -72,7 +72,7 @@
* Name ID Nr of Errors
* PEM 1 9
* PKCS#12 1 4 (Started from top)
* X509 2 18
* X509 2 19
* PKCS5 2 4 (Started from top)
* DHM 3 9
* PK 3 14 (Started from top)

View file

@ -76,6 +76,7 @@
#define MBEDTLS_ERR_X509_BAD_INPUT_DATA -0x2800 /**< Input invalid. */
#define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */
#define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */
#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */
/* \} name */
/**
@ -306,6 +307,15 @@ int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start,
const char *oid, size_t oid_len,
unsigned char *sig, size_t size );
#define MBEDTLS_X509_SAFE_SNPRINTF \
do { \
if( ret < 0 || (size_t) ret >= n ) \
return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL ); \
\
n -= (size_t) ret; \
p += (size_t) ret; \
} while( 0 )
#ifdef __cplusplus
}
#endif