mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-27 03:11:52 +01:00
Fix alignment issue with ATA IDENTIFY structure.
Approved by: re
This commit is contained in:
parent
820e6a1f38
commit
e69811df21
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=195573
@ -1121,7 +1121,7 @@ ataidentify(struct cam_device *device, int retry_count, int timeout)
|
|||||||
{
|
{
|
||||||
union ccb *ccb;
|
union ccb *ccb;
|
||||||
struct ata_params *ident_buf;
|
struct ata_params *ident_buf;
|
||||||
int error = 0;
|
u_int i, error = 0;
|
||||||
int16_t *ptr;
|
int16_t *ptr;
|
||||||
|
|
||||||
ccb = cam_getccb(device);
|
ccb = cam_getccb(device);
|
||||||
@ -1135,22 +1135,21 @@ ataidentify(struct cam_device *device, int retry_count, int timeout)
|
|||||||
bzero(&(&ccb->ccb_h)[1],
|
bzero(&(&ccb->ccb_h)[1],
|
||||||
sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr));
|
sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr));
|
||||||
|
|
||||||
ident_buf = (struct ata_params *)malloc(
|
ptr = (uint16_t *)malloc(sizeof(struct ata_params));
|
||||||
sizeof(struct ata_params));
|
|
||||||
|
|
||||||
if (ident_buf == NULL) {
|
if (ptr == NULL) {
|
||||||
cam_freeccb(ccb);
|
cam_freeccb(ccb);
|
||||||
warnx("can't malloc memory for identify\n");
|
warnx("can't malloc memory for identify\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
bzero(ident_buf, sizeof(*ident_buf));
|
bzero(ptr, sizeof(struct ata_params));
|
||||||
|
|
||||||
cam_fill_ataio(&ccb->ataio,
|
cam_fill_ataio(&ccb->ataio,
|
||||||
retry_count,
|
retry_count,
|
||||||
NULL,
|
NULL,
|
||||||
/*flags*/CAM_DIR_IN,
|
/*flags*/CAM_DIR_IN,
|
||||||
MSG_SIMPLE_Q_TAG,
|
MSG_SIMPLE_Q_TAG,
|
||||||
/*data_ptr*/(u_int8_t *)ident_buf,
|
/*data_ptr*/(u_int8_t *)ptr,
|
||||||
/*dxfer_len*/sizeof(struct ata_params),
|
/*dxfer_len*/sizeof(struct ata_params),
|
||||||
timeout ? timeout : 30 * 1000);
|
timeout ? timeout : 30 * 1000);
|
||||||
// if (periph->path->device->protocol == PROTO_ATA)
|
// if (periph->path->device->protocol == PROTO_ATA)
|
||||||
@ -1172,6 +1171,7 @@ ataidentify(struct cam_device *device, int retry_count, int timeout)
|
|||||||
CAM_EPF_ALL, stderr);
|
CAM_EPF_ALL, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(ptr);
|
||||||
cam_freeccb(ccb);
|
cam_freeccb(ccb);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@ -1188,14 +1188,14 @@ ataidentify(struct cam_device *device, int retry_count, int timeout)
|
|||||||
cam_freeccb(ccb);
|
cam_freeccb(ccb);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
free(ident_buf);
|
free(ptr);
|
||||||
return(error);
|
return(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ptr = (int16_t *)ident_buf;
|
for (i = 0; i < sizeof(struct ata_params) / 2; i++)
|
||||||
ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) {
|
ptr[i] = le16toh(ptr[i]);
|
||||||
*ptr = le16toh(*ptr);
|
ident_buf = (struct ata_params *)ptr;
|
||||||
}
|
|
||||||
if (strncmp(ident_buf->model, "FX", 2) &&
|
if (strncmp(ident_buf->model, "FX", 2) &&
|
||||||
strncmp(ident_buf->model, "NEC", 3) &&
|
strncmp(ident_buf->model, "NEC", 3) &&
|
||||||
strncmp(ident_buf->model, "Pioneer", 7) &&
|
strncmp(ident_buf->model, "Pioneer", 7) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user