aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-05-01 03:43:25 -0700
committerChris Robinson <[email protected]>2023-05-01 03:43:25 -0700
commitbd8c13d7883cb0a570f724885c7a55ad687dada6 (patch)
tree3cafbeece891e9187615ca1dc3b21fb3672ff385 /al
parent0e7d078b01e423e7973cc593046f9716d1ca8c0b (diff)
Fix some debug message length limit checks
Diffstat (limited to 'al')
-rw-r--r--al/debug.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/al/debug.cpp b/al/debug.cpp
index 26a69aff..66cbc622 100644
--- a/al/debug.cpp
+++ b/al/debug.cpp
@@ -134,15 +134,18 @@ FORCE_ALIGN void AL_APIENTRY alDebugMessageInsertSOFT(ALenum source, ALenum type
if(!message)
return context->setError(AL_INVALID_VALUE, "Null message pointer");
+ /* MaxDebugMessageLength is the size including the null terminator,
+ * <length> does not include the null terminator.
+ */
if(length < 0)
{
size_t newlen{std::strlen(message)};
- if(newlen > MaxDebugMessageLength) UNLIKELY
- return context->setError(AL_INVALID_VALUE, "Debug message too long (%zu > %d)", newlen,
- MaxDebugMessageLength);
+ if(newlen >= MaxDebugMessageLength) UNLIKELY
+ return context->setError(AL_INVALID_VALUE, "Debug message too long (%zu >= %d)",
+ newlen, MaxDebugMessageLength);
length = static_cast<ALsizei>(newlen);
}
- else if(length > MaxDebugMessageLength) UNLIKELY
+ else if(length >= MaxDebugMessageLength) UNLIKELY
return context->setError(AL_INVALID_VALUE, "Debug message too long (%d > %d)", length,
MaxDebugMessageLength);