From 6d095a5fb75b8d5cc84a200521db2b498a80b0ea Mon Sep 17 00:00:00 2001 From: marius Date: Sat, 23 Jan 2010 22:38:01 +0000 Subject: On LP64 struct ifid is 64-bit aligned while struct fid is 32-bit aligned so on architectures with strict alignment requirements we can't just simply cast the latter to the former but need to copy it bytewise instead. PR: 143010 MFC after: 3 days --- sys/fs/cd9660/cd9660_vnops.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sys/fs/cd9660/cd9660_vnops.c') diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 55ea46b..5f4780f 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -819,20 +819,25 @@ cd9660_vptofh(ap) struct fid *a_fhp; } */ *ap; { + struct ifid ifh; struct iso_node *ip = VTOI(ap->a_vp); - struct ifid *ifhp; - ifhp = (struct ifid *)ap->a_fhp; - ifhp->ifid_len = sizeof(struct ifid); + ifh.ifid_len = sizeof(struct ifid); - ifhp->ifid_ino = ip->i_number; - ifhp->ifid_start = ip->iso_start; + ifh.ifid_ino = ip->i_number; + ifh.ifid_start = ip->iso_start; + /* + * This intentionally uses sizeof(ifh) in order to not copy stack + * garbage on ILP32. + */ + memcpy(ap->a_fhp, &ifh, sizeof(ifh)); #ifdef ISOFS_DBG printf("vptofh: ino %d, start %ld\n", - ifhp->ifid_ino,ifhp->ifid_start); + ifh.ifid_ino, ifh.ifid_start); #endif - return 0; + + return (0); } /* -- cgit v1.1