Browse Source

ata: apply same change for atapi

K. Lange 2 years ago
parent
commit
96fe218d2f
1 changed files with 2 additions and 1 deletions
  1. 2 1
      modules/ata.c

+ 2 - 1
modules/ata.c

@@ -173,8 +173,9 @@ static uint32_t read_atapi(fs_node_t *node, uint64_t offset, uint32_t size, uint
 		size = i;
 	}
 
-	if (offset % dev->atapi_sector_size) {
+	if (offset % dev->atapi_sector_size || size < dev->atapi_sector_size) {
 		unsigned int prefix_size = (dev->atapi_sector_size - (offset % dev->atapi_sector_size));
+		if (prefix_size > size) prefix_size = size;
 		char * tmp = malloc(dev->atapi_sector_size);
 		ata_device_read_sector_atapi(dev, start_block, (uint8_t *)tmp);