scsi: esp: check buffer length before reading scsi command
The 53C9X Fast SCSI Controller(FSC) comes with an internal 16-byte FIFO buffer. It is used to handle command and data transfer. Routine get_cmd() in non-DMA mode, uses 'ti_size' to read scsi command into a buffer. Add check to validate command length against buffer size to avoid any overrun. Reported-by: Li Qiang <liqiang6-s@360.cn> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Message-Id: <1464717207-7549-1-git-send-email-ppandit@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									943cec86d0
								
							
						
					
					
						commit
						d3cdc49138
					
				@ -98,6 +98,9 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf, uint8_t buflen)
 | 
				
			|||||||
        s->dma_memory_read(s->dma_opaque, buf, dmalen);
 | 
					        s->dma_memory_read(s->dma_opaque, buf, dmalen);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        dmalen = s->ti_size;
 | 
					        dmalen = s->ti_size;
 | 
				
			||||||
 | 
					        if (dmalen > TI_BUFSZ) {
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        memcpy(buf, s->ti_buf, dmalen);
 | 
					        memcpy(buf, s->ti_buf, dmalen);
 | 
				
			||||||
        buf[0] = buf[2] >> 5;
 | 
					        buf[0] = buf[2] >> 5;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user