svn commit: r202903 - head/sys/fs/cd9660
Marius Strobl
marius at FreeBSD.org
Sat Jan 23 22:38:02 UTC 2010
Author: marius
Date: Sat Jan 23 22:38:01 2010
New Revision: 202903
URL: http://svn.freebsd.org/changeset/base/202903
Log:
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
Modified:
head/sys/fs/cd9660/cd9660_vfsops.c
head/sys/fs/cd9660/cd9660_vnops.c
Modified: head/sys/fs/cd9660/cd9660_vfsops.c
==============================================================================
--- head/sys/fs/cd9660/cd9660_vfsops.c Sat Jan 23 22:37:34 2010 (r202902)
+++ head/sys/fs/cd9660/cd9660_vfsops.c Sat Jan 23 22:38:01 2010 (r202903)
@@ -589,17 +589,19 @@ cd9660_fhtovp(mp, fhp, vpp)
struct fid *fhp;
struct vnode **vpp;
{
- struct ifid *ifhp = (struct ifid *)fhp;
+ struct ifid ifh;
struct iso_node *ip;
struct vnode *nvp;
int error;
+ memcpy(&ifh, fhp, sizeof(ifh));
+
#ifdef ISOFS_DBG
printf("fhtovp: ino %d, start %ld\n",
- ifhp->ifid_ino, ifhp->ifid_start);
+ ifh.ifid_ino, ifh.ifid_start);
#endif
- if ((error = VFS_VGET(mp, ifhp->ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) {
+ if ((error = VFS_VGET(mp, ifh.ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) {
*vpp = NULLVP;
return (error);
}
Modified: head/sys/fs/cd9660/cd9660_vnops.c
==============================================================================
--- head/sys/fs/cd9660/cd9660_vnops.c Sat Jan 23 22:37:34 2010 (r202902)
+++ head/sys/fs/cd9660/cd9660_vnops.c Sat Jan 23 22:38:01 2010 (r202903)
@@ -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);
}
/*
More information about the svn-src-all
mailing list