From 732383c0360e8180e063987f83324306fd7c6a84 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 10 Jan 2025 02:06:25 -0500 Subject: [PATCH] limit max sample size when loading .dmf --- src/engine/fileOps/dmf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/fileOps/dmf.cpp b/src/engine/fileOps/dmf.cpp index 6da165ced..d4501a996 100644 --- a/src/engine/fileOps/dmf.cpp +++ b/src/engine/fileOps/dmf.cpp @@ -910,7 +910,8 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { int vol=50; short* data; unsigned char* adpcmData; - if (length<0) { + // I don't think a sample can be that big + if (length<0 || length>(1<<29L)) { logE("invalid sample length %d. are we doing something wrong?",length); lastError="file is corrupt or unreadable at samples"; delete[] file;