From 7e5d0bf132653ab6023a72b259d3a97f951827c2 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 26 Feb 2026 11:17:37 -0800 Subject: [PATCH 1/2] Fix HDR input validation bug with truncated header --- DirectXTex/DirectXTexHDR.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DirectXTex/DirectXTexHDR.cpp b/DirectXTex/DirectXTexHDR.cpp index b3502f00..33e50434 100644 --- a/DirectXTex/DirectXTexHDR.cpp +++ b/DirectXTex/DirectXTexHDR.cpp @@ -219,7 +219,7 @@ namespace } } - if (!formatFound) + if (!formatFound || (size < 3)) { return E_FAIL; } From 45928be68ba47588f3a1891e03fc8071a106bdff Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 26 Feb 2026 16:48:36 -0800 Subject: [PATCH 2/2] Fix test for supported vs. unsupported orientation --- DirectXTex/DirectXTexHDR.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DirectXTex/DirectXTexHDR.cpp b/DirectXTex/DirectXTexHDR.cpp index 33e50434..f2572ad7 100644 --- a/DirectXTex/DirectXTexHDR.cpp +++ b/DirectXTex/DirectXTexHDR.cpp @@ -227,7 +227,7 @@ namespace // Get orientation char orientation[256] = {}; - const size_t len = FindEOL(info, std::min(sizeof(orientation), size - 1)); + const size_t len = FindEOL(info, std::min(sizeof(orientation) - 1, size)); if (len == size_t(-1) || len <= 2) { @@ -236,7 +236,7 @@ namespace strncpy_s(orientation, info, len); - if (orientation[0] != '-' && orientation[1] != 'Y') + if (orientation[0] != '-' || orientation[1] != 'Y') { // We only support the -Y +X orientation (see top of file) return (static_cast(((orientation[0] == '+' || orientation[0] == '-') && (orientation[1] == 'X' || orientation[1] == 'Y'))))