X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fide.c;h=e9a90a84342d83f286c86c9fa2efb6da31f047d3;hb=d775bbfa668ce9968bacc0e4257cf86e5ab88e90;hp=bf842e92d00bf4d3d56d15edb5af20f2919f6b06;hpb=2282a040e60b24d3fb7c48bb197c5bff6636df67;p=palacios.git diff --git a/palacios/src/devices/ide.c b/palacios/src/devices/ide.c index bf842e9..e9a90a8 100644 --- a/palacios/src/devices/ide.c +++ b/palacios/src/devices/ide.c @@ -299,7 +299,12 @@ static inline int get_channel_index(ushort_t port) { static inline struct ide_channel * get_selected_channel(struct ide_internal * ide, ushort_t port) { int channel_idx = get_channel_index(port); - return &(ide->channels[channel_idx]); + if (channel_idx >= 0) { + return &(ide->channels[channel_idx]); + } else { + PrintError(VM_NONE,VCORE_NONE,"ide: Cannot Determine Selected Channel\n"); + return 0; + } } static inline struct ide_drive * get_selected_drive(struct ide_channel * channel) { @@ -1082,7 +1087,7 @@ static int read_hd_data(uint8_t * dst, uint64_t length, struct ide_internal * id drive->transfer_index, drive->transfer_length, drive->hd_state.cur_sector_num); - if (drive->transfer_index >= drive->transfer_length) { + if (drive->transfer_index >= drive->transfer_length && drive->transfer_index>=DATA_BUFFER_SIZE) { PrintError(VM_NONE, VCORE_NONE, "Buffer overrun... (xfer_len=%llu) (cur_idx=%llu) (post_idx=%llu)\n", drive->transfer_length, drive->transfer_index, drive->transfer_index + length); @@ -1224,7 +1229,7 @@ static int read_cd_data(uint8_t * dst, uint64_t length, struct ide_internal * id - if (drive->transfer_index >= drive->transfer_length) { + if (drive->transfer_index >= drive->transfer_length && drive->transfer_index>=DATA_BUFFER_SIZE) { PrintError(VM_NONE, VCORE_NONE, "Buffer Overrun... (xfer_len=%llu) (cur_idx=%llu) (post_idx=%llu)\n", drive->transfer_length, drive->transfer_index, drive->transfer_index + length); @@ -1990,7 +1995,8 @@ static int connect_fn(struct v3_vm_info * vm, } if (model_str != NULL) { - strncpy(drive->model, model_str, sizeof(drive->model) - 1); + strncpy(drive->model, model_str, sizeof(drive->model)); + drive->model[sizeof(drive->model)-1] = 0; } if (strcasecmp(type_str, "cdrom") == 0) {