diff --git a/src/lib/asn1/ASN1Reader.cpp b/src/lib/asn1/ASN1Reader.cpp index 6ac0605149d0fc..30b8f1c493cb58 100644 --- a/src/lib/asn1/ASN1Reader.cpp +++ b/src/lib/asn1/ASN1Reader.cpp @@ -53,7 +53,9 @@ CHIP_ERROR ASN1Reader::Next() ReturnErrorCodeIf(EndOfContents, ASN1_END); ReturnErrorCodeIf(IndefiniteLen, ASN1_ERROR_UNSUPPORTED_ENCODING); - mElemStart += (mHeadLen + ValueLen); + // Note: avoid using addition assignment operator (+=), which may result in integer overflow + // in the right hand side of an assignment (mHeadLen + ValueLen). + mElemStart = mElemStart + mHeadLen + ValueLen; ResetElementState();