Merge pull request #54 from henrygab/patch-2

Avoid returning uninitialized memory
This commit is contained in:
hathach 2019-03-13 01:08:06 -07:00 committed by GitHub
commit 73456ac80e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
{ {
void const* response = NULL; void const* response = NULL;
int32_t resplen = 0; int32_t resplen = 0;
memset(buffer, 0, bufsize);
switch ( scsi_cmd[0] ) switch ( scsi_cmd[0] )
{ {
@ -114,6 +115,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
{ {
(void) lun; (void) lun;
memset(buffer, 0, bufsize);
// since we return block size each, offset should always be zero // since we return block size each, offset should always be zero
TU_ASSERT(offset == 0, -1); TU_ASSERT(offset == 0, -1);