Skip to content

Commit

Permalink
HDR fuzz test
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed May 1, 2024
1 parent 7286427 commit 56d74f1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions hdr/crash-f83c7fbad7278ad0a3d7bf061901d6a459cd5e42.hdr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#?RADIANCEFORMAT= 32-bit_rle_rgbe E#
22 changes: 18 additions & 4 deletions hdr/hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ bool Test06()
return false;
}

bool second = false;

wchar_t szPath[MAX_PATH] = {};
wcscpy_s(szPath, szMediaPath);
wcscat_s(szPath, L"*.*");
Expand Down Expand Up @@ -844,7 +846,7 @@ bool Test06()
print(".");
}

wcscpy_s(szPath, szMediaPath);
wcscpy_s(szPath, (second) ? L"" : szMediaPath);
wcscat_s(szPath, findData.cFileName);

bool ishdr = false;
Expand Down Expand Up @@ -878,7 +880,7 @@ bool Test06()

if (FAILED(hr) && ishdr)
{
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED))
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) && !second)
{
success = false;
printe("ERROR: frommemory expected success! (%08X)\n%ls\n", static_cast<unsigned int>(hr), szPath);
Expand All @@ -901,7 +903,7 @@ bool Test06()

if (FAILED(hr) && ishdr)
{
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED))
if (hr != HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) && !second)
{
success = false;
printe("ERROR: fromfile expected success ! (%08X)\n%ls\n", static_cast<unsigned int>(hr), szPath);
Expand All @@ -916,7 +918,19 @@ bool Test06()
}

if (!FindNextFile(hFile.get(), &findData))
break;
{
if (second)
break;

hFile.reset(safe_handle(FindFirstFileEx(L"*.hdr",
FindExInfoBasic, &findData,
FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH)));
if (!hFile)
break;

second = true;
}
}

if (!ncount)
Expand Down

0 comments on commit 56d74f1

Please sign in to comment.