[tor-bugs] #22521 [Core Tor/Tor]: use offsetof() instead of rolling our own
Tor Bug Tracker & Wiki
blackhole at torproject.org
Wed Jun 7 15:31:31 UTC 2017
#22521: use offsetof() instead of rolling our own
------------------------------+--------------------------------
Reporter: catalyst | Owner: catalyst
Type: defect | Status: new
Priority: Medium | Milestone: Tor: 0.3.2.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Keywords:
Actual Points: | Parent ID:
Points: | Reviewer:
Sponsor: |
------------------------------+--------------------------------
`src/common/util.h` defines a `STRUCT_OFFSET()` macro that effectively
duplicates `offsetof()`, which has been available in `stddef.h` since C89.
The non-GCC version of `STRUCT_OFFSET()` does pointer arithmetic on null
pointers, which is undefined behavior.
We should use the standard `offsetof()` macro instead, unless there's some
reason we still need to support platforms that lack it.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22521>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list