Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #3596

Closed
Open
Created Jul 14, 2011 by Zack Weinberg@zwol

obfsproxy: don't reinvent offsetof

Change 9d96eb94 introduced a bogon to util.h:

#define OFFSETOF(container_type, element) \ (((char*)&((container_type*)0)->element) - ((char*) ((container_type*)0)))

It is not necessary to reinvent this particular wheel -- stddef.h, which is part of C89 and is well-supported everywhere, provides offsetof -- and it's actually wrong: there is a dereference of the null pointer here, and that causes undefined behavior, even when it's inside the operand of &. (I am not aware of any compiler that presently generates "incorrect" results for this construct, but it did cause the compiler itself to crash in some (probably never-released) versions of GCC: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17396 .)

Please apply attached patch. I also renamed UPCAST to DOWNCAST, consistent with C++ terminology (the type is becoming more specific, that's downward).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking