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

Security fixes and code cleanups #4055

Merged
merged 9 commits into from Jul 24, 2017

Fixed resource cleanup.

  • Loading branch information...
akallabeth committed Jul 13, 2017
commit 478ca97a1687c2e92fbf46987b2b4085c9a6c648
@@ -735,6 +735,19 @@ static UINT drive_irp_request(DEVICE* device, IRP* irp)
return CHANNEL_RC_OK;
}
static void drive_free_resources(DRIVE_DEVICE* drive)
{
if (!drive)
return;
CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
}
/**
* Function description
*
@@ -753,12 +766,7 @@ static UINT drive_free(DEVICE* device)
return error;
}
CloseHandle(drive->thread);
ListDictionary_Free(drive->files);
MessageQueue_Free(drive->IrpQueue);
Stream_Free(drive->device.data, TRUE);
free(drive->path);
free(drive);
drive_free_resources(drive);
return error;
}
@@ -866,7 +874,7 @@ UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
return CHANNEL_RC_OK;
out_error:
drive_free((DEVICE*) drive);
drive_free_resources(drive);
return error;
}
@@ -182,8 +182,9 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
UINT32 tmp;
size_t pos1, pos2;
wStream* s;
RDPGFX_AVC444_BITMAP_STREAM h264;
RDPGFX_AVC444_BITMAP_STREAM h264 = { 0 };
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
s = Stream_New(cmd->data, cmd->length);
if (!s)
@@ -193,21 +194,26 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
}
if (Stream_GetRemainingLength(s) < 4)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
Stream_Read_UINT32(s, tmp);
h264.cbAvc420EncodedBitstream1 = tmp & 0x3FFFFFFFUL;
h264.LC = (tmp >> 30UL) & 0x03UL;
if (h264.LC == 0x03)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
pos1 = Stream_GetPosition(s);
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[0].meta))))
{
WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
return error;
goto fail;
}
pos2 = Stream_GetPosition(s);
@@ -218,15 +224,18 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
tmp = h264.cbAvc420EncodedBitstream1 - pos2 + pos1;
if (Stream_GetRemainingLength(s) < tmp)
return ERROR_INVALID_DATA;
{
error = ERROR_INVALID_DATA;
goto fail;
}
h264.bitstream[0].length = tmp;
Stream_Seek(s, tmp);
if ((error = rdpgfx_read_h264_metablock(gfx, s, &(h264.bitstream[1].meta))))
{
WLog_ERR(TAG, "rdpgfx_read_h264_metablock failed with error %"PRIu32"!", error);
return error;
goto fail;
}
h264.bitstream[1].data = Stream_Pointer(s);
@@ -238,7 +247,6 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
memset(&h264.bitstream[1], 0, sizeof(h264.bitstream[1]));
}
Stream_Free(s, FALSE);
cmd->extra = (void*) &h264;
if (context)
@@ -249,6 +257,8 @@ static UINT rdpgfx_decode_AVC444(RDPGFX_PLUGIN* gfx, RDPGFX_SURFACE_COMMAND* cmd
WLog_ERR(TAG, "context->SurfaceCommand failed with error %"PRIu32"", error);
}
fail:
Stream_Free(s, FALSE);
free(h264.bitstream[0].meta.regionRects);
free(h264.bitstream[0].meta.quantQualityVals);
free(h264.bitstream[1].meta.regionRects);
ProTip! Use n and p to navigate between commits in a pull request.