Skip to content

Commit 7e0ef29

Browse files
authored
HDR file input validation fixes (#676)
1 parent ce7c447 commit 7e0ef29

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

DirectXTex/DirectXTexHDR.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ namespace
219219
}
220220
}
221221

222-
if (!formatFound)
222+
if (!formatFound || (size < 3))
223223
{
224224
return E_FAIL;
225225
}
226226

227227
// Get orientation
228228
char orientation[256] = {};
229229

230-
const size_t len = FindEOL(info, std::min<size_t>(sizeof(orientation), size - 1));
230+
const size_t len = FindEOL(info, std::min<size_t>(sizeof(orientation) - 1, size));
231231
if (len == size_t(-1)
232232
|| len <= 2)
233233
{
@@ -236,7 +236,7 @@ namespace
236236

237237
strncpy_s(orientation, info, len);
238238

239-
if (orientation[0] != '-' && orientation[1] != 'Y')
239+
if (orientation[0] != '-' || orientation[1] != 'Y')
240240
{
241241
// We only support the -Y +X orientation (see top of file)
242242
return (static_cast<unsigned long>(((orientation[0] == '+' || orientation[0] == '-') && (orientation[1] == 'X' || orientation[1] == 'Y'))))

0 commit comments

Comments
 (0)