Attachment "992f94d847.diff" to
ticket [992f94d847]
added by
chrstphrchvz
2021-12-11 00:21:32.
diff --git macosx/tclMacOSXFCmd.c macosx/tclMacOSXFCmd.c
index 6275aac40..66582efe0 100644
--- macosx/tclMacOSXFCmd.c
+++ macosx/tclMacOSXFCmd.c
@@ -142,7 +142,7 @@ TclMacOSXGetFileAttribute(
struct attrlist alist;
fileinfobuf finfo;
finderinfo *finder = (finderinfo *) &finfo.data;
- off_t *rsrcForkSize = (off_t *) &finfo.data;
+ off_t rsrcForkSize;
const char *native;
result = TclpObjStat(fileName, &statBuf);
@@ -196,7 +196,9 @@ TclMacOSXGetFileAttribute(
(finder->fdFlags & kFinfoIsInvisible) != 0);
break;
case MACOSX_RSRCLENGTH_ATTRIBUTE:
+ /* finfo.data is not necessarily 8-byte aligned */
+ memcpy(&rsrcForkSize, &finfo.data, sizeof(rsrcForkSize));
- *attributePtrPtr = Tcl_NewWideIntObj(*rsrcForkSize);
+ *attributePtrPtr = Tcl_NewWideIntObj(rsrcForkSize);
break;
}
return TCL_OK;
@@ -238,7 +240,7 @@ TclMacOSXSetFileAttribute(
struct attrlist alist;
fileinfobuf finfo;
finderinfo *finder = (finderinfo *) &finfo.data;
- off_t *rsrcForkSize = (off_t *) &finfo.data;
+ off_t rsrcForkSize;
const char *native;
result = TclpObjStat(fileName, &statBuf);
@@ -324,7 +326,9 @@ TclMacOSXSetFileAttribute(
return TCL_ERROR;
}
+ /* finfo.data is not necessarily 8-byte aligned */
+ memcpy(&rsrcForkSize, &finfo.data, sizeof(rsrcForkSize));
- if (newRsrcForkSize != *rsrcForkSize) {
+ if (newRsrcForkSize != rsrcForkSize) {
Tcl_DString ds;
/*