summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-02-20 15:45:56 +0200
committerToomas Soome <tsoome@me.com>2019-02-22 19:44:30 +0200
commit57aea9348dbfeb813b16956eec292357525e2f66 (patch)
treec1b60d6933e6163eca87fd93678dd9face5e0bae
parent54bc10fe6ad8a64fc279dc5fba56eaafea7ec2c0 (diff)
downloadillumos-joyent-57aea9348dbfeb813b16956eec292357525e2f66.tar.gz
10429 loader: dereferencing type-punned pointer will break strict-aliasing rules
Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/boot/sys/boot/i386/isoboot/cd9660read.c2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/biospnp.c40
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/bootinfo32.c4
3 files changed, 24 insertions, 22 deletions
diff --git a/usr/src/boot/sys/boot/i386/isoboot/cd9660read.c b/usr/src/boot/sys/boot/i386/isoboot/cd9660read.c
index 6cfa8d304f..f1e43d7a74 100644
--- a/usr/src/boot/sys/boot/i386/isoboot/cd9660read.c
+++ b/usr/src/boot/sys/boot/i386/isoboot/cd9660read.c
@@ -245,7 +245,7 @@ cd9660_lookup(const char *path)
break;
}
- rec = *(struct iso_directory_record *)vd->root_directory_record;
+ bcopy(vd->root_directory_record, &rec, sizeof (rec));
if (*path == '/') path++; /* eat leading '/' */
first = 1;
diff --git a/usr/src/boot/sys/boot/i386/libi386/biospnp.c b/usr/src/boot/sys/boot/i386/libi386/biospnp.c
index 30e55fc893..df64ba9582 100644
--- a/usr/src/boot/sys/boot/i386/libi386/biospnp.c
+++ b/usr/src/boot/sys/boot/i386/libi386/biospnp.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
@@ -25,7 +25,6 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
/*
* PnP BIOS enumerator.
@@ -249,44 +248,47 @@ biospnp_call(int func, const char *fmt, ...)
{
va_list ap;
const char *p;
- u_int8_t *argp;
- u_int32_t args[4];
- u_int32_t i;
+ uint8_t *argp;
+ uint16_t int16;
+ uint32_t args[4];
+ uint32_t i;
/* function number first */
- argp = (u_int8_t *)args;
- *(u_int16_t *)argp = func;
- argp += sizeof(u_int16_t);
+ argp = (uint8_t *)args;
+ int16 = func;
+ bcopy(&int16, argp, sizeof (int16));
+ argp += sizeof(uint16_t);
/* take args according to format */
va_start(ap, fmt);
for (p = fmt; *p != 0; p++) {
switch(*p) {
-
case 'w':
- i = va_arg(ap, u_int);
- *(u_int16_t *)argp = i;
- argp += sizeof(u_int16_t);
+ i = va_arg(ap, uint32_t);
+ int16 = i;
+ bcopy(&int16, argp, sizeof (int16));
+ argp += sizeof (uint16_t);
break;
case 'l':
- i = va_arg(ap, u_int32_t);
- *(u_int32_t *)argp = i;
- argp += sizeof(u_int32_t);
+ i = va_arg(ap, uint32_t);
+ bcopy(&i, argp, sizeof (i));
+ argp += sizeof (uint32_t);
break;
}
}
va_end(ap);
/* BIOS segment last */
- *(u_int16_t *)argp = pnp_Icheck->pnp_rmds;
- argp += sizeof(u_int16_t);
+ int16 = pnp_Icheck->pnp_rmds;
+ bcopy(&int16, argp, sizeof (int16));
+ argp += sizeof(uint16_t);
/* prepare for call */
v86.ctl = V86_ADDR | V86_CALLF;
- v86.addr = ((u_int32_t)pnp_Icheck->pnp_rmcs << 16) + pnp_Icheck->pnp_rmip;
+ v86.addr = ((uint32_t)pnp_Icheck->pnp_rmcs << 16) + pnp_Icheck->pnp_rmip;
/* call with packed stack and return */
v86bios(args[0], args[1], args[2], args[3]);
- return(v86.eax & 0xffff);
+ return (v86.eax & 0xffff);
}
diff --git a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
index adf5d514a5..fda7db76ad 100644
--- a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
+++ b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c
@@ -233,10 +233,10 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t
ssym = esym = 0;
md = file_findmetadata(kfp, MODINFOMD_SSYM);
if (md != NULL)
- ssym = *((vm_offset_t *)&(md->md_data));
+ bcopy(&md->md_data, &ssym, sizeof (vm_offset_t));
md = file_findmetadata(kfp, MODINFOMD_ESYM);
if (md != NULL)
- esym = *((vm_offset_t *)&(md->md_data));
+ bcopy(&md->md_data, &esym, sizeof (vm_offset_t));
if (ssym == 0 || esym == 0)
ssym = esym = 0; /* sanity */