summaryrefslogtreecommitdiff
path: root/include/mbedtls/x509.h
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2015-06-22 11:12:02 +0200
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2015-06-22 14:42:04 +0200
commit1685368408dc8cbb8a26e22c39fb3f2cdf1c76dc (patch)
treeb2fd4f1c12f9cf51a756611232bbcff68f18600c /include/mbedtls/x509.h
parent7b6dcbe99328e18e1813298001f200d08dd0fe71 (diff)
Rationalize snprintf() usage in X.509 modules
Diffstat (limited to 'include/mbedtls/x509.h')
-rw-r--r--include/mbedtls/x509.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/mbedtls/x509.h b/include/mbedtls/x509.h
index 2afe4fa7..59986d83 100644
--- a/include/mbedtls/x509.h
+++ b/include/mbedtls/x509.h
@@ -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