Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newfs_udf Address of packed member might not be aligned.
details: https://anonhg.NetBSD.org/src/rev/c4e877792d29
branches: trunk
changeset: 446527:c4e877792d29
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 09 17:52:48 2018 +0000
description:
Address of packed member might not be aligned.
diffstat:
sbin/newfs_udf/udf_create.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diffs (79 lines):
diff -r 6890851851aa -r c4e877792d29 sbin/newfs_udf/udf_create.c
--- a/sbin/newfs_udf/udf_create.c Sun Dec 09 17:33:38 2018 +0000
+++ b/sbin/newfs_udf/udf_create.c Sun Dec 09 17:52:48 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_create.c,v 1.25 2015/06/16 23:18:55 christos Exp $ */
+/* $NetBSD: udf_create.c,v 1.26 2018/12/09 17:52:48 christos Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -30,7 +30,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: udf_create.c,v 1.25 2015/06/16 23:18:55 christos Exp $");
+__RCSID("$NetBSD: udf_create.c,v 1.26 2018/12/09 17:52:48 christos Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -1720,10 +1720,10 @@
struct extfile_entry *efe;
struct extattrhdr_desc *extattrhdr;
struct impl_extattr_entry *implext;
- uint32_t impl_attr_loc, appl_attr_loc, l_ea, a_l, exthdr_len;
- uint32_t *l_eap, l_ad;
+ uint32_t impl_attr_loc, appl_attr_loc, l_ea, l_ad, a_l;
uint16_t *spos;
uint8_t *bpos, *data;
+ void *l_eap;
if (udf_rw16(dscr->tag.id) == TAGID_FENTRY) {
fe = &dscr->fe;
@@ -1741,20 +1741,22 @@
/* should have a header! */
extattrhdr = (struct extattrhdr_desc *) data;
- l_ea = udf_rw32(*l_eap);
+ memcpy(&l_ea, l_eap, sizeof(l_ea));
+ l_ea = udf_rw32(l_ea);
if (l_ea == 0) {
+ uint32_t exthdr_len;
assert(l_ad == 0);
/* create empty extended attribute header */
- exthdr_len = sizeof(struct extattrhdr_desc);
+ l_ea = sizeof(struct extattrhdr_desc);
+ exthdr_len = udf_rw32(l_ea);
udf_inittag(&extattrhdr->tag, TAGID_EXTATTR_HDR, /* loc */ 0);
- extattrhdr->impl_attr_loc = udf_rw32(exthdr_len);
- extattrhdr->appl_attr_loc = udf_rw32(exthdr_len);
+ extattrhdr->impl_attr_loc = exthdr_len;
+ extattrhdr->appl_attr_loc = exthdr_len;
extattrhdr->tag.desc_crc_len = udf_rw16(8);
/* record extended attribute header length */
- l_ea = exthdr_len;
- *l_eap = udf_rw32(l_ea);
+ memcpy(l_eap, &exthdr_len, sizeof(exthdr_len));
}
/* extract locations */
@@ -1787,7 +1789,7 @@
assert(appl_attr_loc == l_ea);
/* append the attribute at the end of the current space */
- bpos = data + udf_rw32(*l_eap);
+ bpos = data + l_ea;
a_l = udf_rw32(extattr->a_l);
/* update impl. attribute locations */
@@ -1802,7 +1804,8 @@
/* copy and advance */
memcpy(bpos, extattr, a_l);
l_ea += a_l;
- *l_eap = udf_rw32(l_ea);
+ l_ea = udf_rw32(l_ea);
+ memcpy(l_eap, &l_ea, sizeof(l_ea));
/* do the `dance` again backwards */
if (context.dscrver != 2) {
Home |
Main Index |
Thread Index |
Old Index