mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-20 20:37:27 +01:00
Land #117 - handle zero-byte reads and writes gracefully
This commit is contained in:
commit
237897c218
@ -26,7 +26,7 @@ static DWORD file_channel_write(Channel *channel, Packet *request,
|
|||||||
DWORD written = 0;
|
DWORD written = 0;
|
||||||
|
|
||||||
// Write a chunk
|
// Write a chunk
|
||||||
if ((written = (DWORD)fwrite(buffer, 1, bufferSize, ctx->fd)) <= 0)
|
if (bufferSize && (written = (DWORD)fwrite(buffer, 1, bufferSize, ctx->fd)) <= 0)
|
||||||
{
|
{
|
||||||
written = 0;
|
written = 0;
|
||||||
result = GetLastError();
|
result = GetLastError();
|
||||||
@ -67,7 +67,7 @@ static DWORD file_channel_read(Channel *channel, Packet *request,
|
|||||||
DWORD bytes = 0;
|
DWORD bytes = 0;
|
||||||
|
|
||||||
// Read a chunk
|
// Read a chunk
|
||||||
if ((bytes= (DWORD)fread(buffer, 1, bufferSize, ctx->fd)) <= 0)
|
if (bufferSize && (bytes= (DWORD)fread(buffer, 1, bufferSize, ctx->fd)) <= 0)
|
||||||
{
|
{
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
result = GetLastError();
|
result = GetLastError();
|
||||||
|
Loading…
Reference in New Issue
Block a user