From 6a2975c7423ece095898eee059e7ecbd97cca160 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 13 Dec 2019 12:13:38 +1000 Subject: [PATCH] DecodePolicyOID - check out index --- wolfcrypt/src/asn.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index ed698f32d..c9ad3fec6 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -7792,7 +7792,7 @@ int DecodePolicyOID(char *out, word32 outSz, const byte *in, word32 inSz) outIdx += w; val = 0; - do { + while (inIdx < inSz && outIdx < outSz) { /* extract the next OID digit from in to val */ /* first bit is used to set if value is coded on 1 or multiple bytes */ if (in[inIdx] & 0x80) { @@ -7809,7 +7809,9 @@ int DecodePolicyOID(char *out, word32 outSz, const byte *in, word32 inSz) val = 0; } inIdx++; - } while (inIdx < inSz); + } + if (outIdx == outSz) + outIdx--; out[outIdx] = 0; w = (int)outIdx;