Remove undefined behavior in net sockaddr usage

Remove potential undefined behavior in networking code.
Not Available
Check Out Task
Task Bounty Details


Bitcoin Issue


Estimated Effort

Not Available

Current Status


Paid in USD or equivalent BTC upon acceptance

Bitcoin Issue

From the original issue:

Bitcoin code does contain UB [undefined behavior] in the net code in particular. All of the code that works with `struct sockaddr` needs to be inspected and fixed. For example here:

bitcoin/src/netaddress.cpp (Line 988 in b620b2d)

`struct sockaddr_in *paddrin = (struct sockaddr_in*)paddr;`

It is illegal/UB in C++ to do this type of aliasing and dereference a pointer that is reinterpre_casted in this way. C++ has stricter aliasing rules than C. For reference, see this:

Good knowledge of C/C++ is recommended.

Prerequisite Skills


Code Guidelines

Repository Code Guidelines Page

Definition of Done

Get a PR merged which closes the original issue

Check Out Task