From 4a5c0ed4e2e1784dab9869f91e9feaabe8c1cc43 Mon Sep 17 00:00:00 2001 From: "John J. Jordan" Date: Tue, 3 Apr 2018 02:10:47 -0700 Subject: [PATCH] Prevent underflow in tag reader --- src/MACLib/APETag.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MACLib/APETag.cpp b/src/MACLib/APETag.cpp index 435d9a6..2fedcbe 100644 --- src/MACLib/APETag.cpp +++ src/MACLib/APETag.cpp @@ -504,7 +504,8 @@ int CAPETag::LoadField(const char * pBuffer, int nMaximumBytes, int * pBytes) // safety check (so we can't get buffer overflow attacked) int nMaximumRead = nMaximumBytes - 8 - nFieldValueSize; - BOOL bSafe = TRUE; + // guard against underflow + BOOL bSafe = nMaximumRead > 0; for (int z = 0; (z < nMaximumRead) && (bSafe == TRUE); z++) { int nCharacter = pBuffer[nLocation + z];