Test and fix x509_oid functions
This commit is contained in:
parent
6c1a73e061
commit
7afdb88216
8 changed files with 91 additions and 10 deletions
|
@ -655,6 +655,8 @@ void polarssl_strerror( int ret, char *buf, size_t buflen )
|
|||
#if defined(POLARSSL_OID_C)
|
||||
if( use_ret == -(POLARSSL_ERR_OID_NOT_FOUND) )
|
||||
snprintf( buf, buflen, "OID - OID is not found" );
|
||||
if( use_ret == -(POLARSSL_ERR_OID_BUF_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "OID - output buffer is too small" );
|
||||
#endif /* POLARSSL_OID_C */
|
||||
|
||||
#if defined(POLARSSL_PADLOCK_C)
|
||||
|
|
|
@ -590,16 +590,14 @@ static int compat_snprintf(char *str, size_t size, const char *format, ...)
|
|||
#define snprintf compat_snprintf
|
||||
#endif
|
||||
|
||||
#define POLARSSL_ERR_DEBUG_BUF_TOO_SMALL -2
|
||||
|
||||
#define SAFE_SNPRINTF() \
|
||||
{ \
|
||||
if( ret == -1 ) \
|
||||
return( -1 ); \
|
||||
return POLARSSL_ERR_OID_BUF_TOO_SMALL; \
|
||||
\
|
||||
if ( (unsigned int) ret > n ) { \
|
||||
if ( (unsigned int) ret >= n ) { \
|
||||
p[n - 1] = '\0'; \
|
||||
return POLARSSL_ERR_DEBUG_BUF_TOO_SMALL;\
|
||||
return POLARSSL_ERR_OID_BUF_TOO_SMALL; \
|
||||
} \
|
||||
\
|
||||
n -= (unsigned int) ret; \
|
||||
|
@ -630,7 +628,7 @@ int oid_get_numeric_string( char *buf, size_t size,
|
|||
{
|
||||
/* Prevent overflow in value. */
|
||||
if ( ( ( value << 7 ) >> 7 ) != value )
|
||||
return( POLARSSL_ERR_DEBUG_BUF_TOO_SMALL );
|
||||
return( POLARSSL_ERR_OID_BUF_TOO_SMALL );
|
||||
|
||||
value <<= 7;
|
||||
value += oid->p[i] & 0x7F;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue