... in get_interface_addresses_ioctl().
This pointer alignment issue exists on x86_64 macOS, but is unlikely to exist
elsewhere. (i386 macOS only requires 4-byte alignment, and other OSs have
8-byte ints.)
Fixes bug 24733; not in any released version of tor.
--- /dev/null
+ o Minor bugfixes (code correctness):
+ - Stop invoking undefined behaviour by using tor_free() on an unaligned
+ pointer in get_interface_addresses_ioctl(). This pointer alignment issue
+ exists on x86_64 macOS, but is unlikely to exist elsewhere.
+ Fixes bug 24733; bugfix on 0.3.0.0-alpha-dev;
+ not in any released version of tor.
done:
if (fd >= 0)
close(fd);
- tor_free(ifc.ifc_buf);
+ /* On macOS, tor_free() loads ifc.ifc_buf, which leads to undefined
+ * behaviour, because it is always aligned at 8-bytes (ifc) plus 4 bytes
+ * (ifc_len and pragma pack(4)). So we use raw_free() instead. */
+ raw_free(ifc.ifc_buf);
+ ifc.ifc_buf = NULL;
return result;
}
#endif /* defined(HAVE_IFCONF_TO_SMARTLIST) */