Topic: Bug in asn.c GetCertHeader()

In GetCertHeader(..) this variable is declared:

mp_int mpi;

and then hopefully initialized later on in GetInt(...)

however if GetInt fails then, instead of returning
ret is set to ASN_PARSE_E

it looks like this ret value is then ignored later on
so I assume the intention was to write

return ASN_PARSE_E;
instead of
ret = ASN_PARSE_E;

Since mp_int is not nulled or anything, attempting
to free it in mp_init will causes a crash.



Re: Bug in asn.c GetCertHeader()

A unified diff of the patch I applied.

/cyassl-1.9.0/ctaocrypt/src/asn.c |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cyassl-1.9.0/ctaocrypt/src/asn.c b/cyassl-1.9.0/ctaocrypt/src/asn.c
index 844ab71..2ec8eec 100644
--- a/cyassl-1.9.0/ctaocrypt/src/asn.c
+++ b/cyassl-1.9.0/ctaocrypt/src/asn.c
@@ -716,7 +716,7 @@ static int GetCertHeader(DecodedCert* cert, word32 inSz)
         return ASN_PARSE_E;

     if (GetInt(&mpi, cert->source, &cert->srcIdx) < 0)
-        ret = ASN_PARSE_E;
+        return ASN_PARSE_E;

     return ret;


Re: Bug in asn.c GetCertHeader()

Thanks for the patch!  It's been pushed to our embedded SSL library on github.