-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Issues with IIS ReadFileChunk #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Good bugs, I added the fixes, except for the page size. AFAIK the pattern we use right now, with checking the page size through system info, is the robust one, but I'll double check. |
Ok, I think that will work. |
That piece of code is used in IIS modules that ship with the server or one of its components and it is quite old. With SSDs becoming more popular and RAM still getting cheaper, would it make sense to allocate a multiply of the page size? |
Typing this off the top of my head :), so mind any typos.
IIS function HRESULT CMyHttpModule::ReadFileChunk(HTTP_DATA_CHUNK *chunk, char *buf)
fails in the following cases:
Fix:
memcpy(buf, pIoBuffer, bytesRead);
to
memcpy(buf, pIoBuffer+dwDataStartOffset, bytesRead);
The guarding statement checking bytesRead against the length will not work with multiple page reads.
Fix:
if (bytesRead > chunk->FromFileHandle.ByteRange.Length.QuadPart) { bytesRead = (DWORD)chunk->FromFileHandle.ByteRange.Length.QuadPart; }
if ((bytesTotal+bytesRead) > chunk->FromFileHandle.ByteRange.Length.QuadPart) { bytesRead = chunk->FromFileHandle.ByteRange.Length.QuadPart-bytesTotal; }
Regards,
Kees
The text was updated successfully, but these errors were encountered: