From b6e81bc3d7ba726a9dbc72b4127e31be2fc1ab41 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Tue, 20 Feb 2018 11:20:09 -0500 Subject: [PATCH] ECP: Add a sanity check to mbedtls_ecp_ansi_write_group Check for p != q at the end to ensure that everything went as it should. --- library/ecp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/ecp.c b/library/ecp.c index 477ed0d6b..89b0af44a 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -2082,6 +2082,8 @@ int mbedtls_ecp_ansi_write_group( const mbedtls_ecp_group *grp, return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); q = p + 2 + oid_length; *olen = mbedtls_asn1_write_oid( &q, p, oid, oid_length ); + if ( p != q ) + return ( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); return ( 0 ); }