Fix dynamic SCSI buffer window sizing causing SEGV
This commit is contained in:
@@ -29,6 +29,7 @@ typedef struct scsi_disk_t {
|
||||
void * log;
|
||||
|
||||
uint8_t * temp_buffer;
|
||||
size_t temp_buffer_sz;
|
||||
uint8_t atapi_cdb[16];
|
||||
uint8_t current_cdb[16];
|
||||
uint8_t sense[256];
|
||||
|
||||
@@ -623,8 +623,15 @@ static void
|
||||
scsi_disk_buf_alloc(scsi_disk_t *dev, uint32_t len)
|
||||
{
|
||||
scsi_disk_log(dev->log, "Allocated buffer length: %i\n", len);
|
||||
if (dev->temp_buffer == NULL)
|
||||
if (dev->temp_buffer == NULL) {
|
||||
dev->temp_buffer = (uint8_t *) malloc(len);
|
||||
dev->temp_buffer_sz = len;
|
||||
}
|
||||
if (len > dev->temp_buffer_sz) {
|
||||
uint8_t *buf = (uint8_t *) realloc(dev->temp_buffer, len);
|
||||
dev->temp_buffer = buf;
|
||||
dev->temp_buffer_sz = len;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user