You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] simplex-talk server: addr_len passed to accept() is uninitialized (Undefined Behavior) #100
Description
In the simplex-talk server code (Chapter 1.4, Software), the variable addr_len is passed to accept() without being initialized. Reading this uninitialized variable is Undefined Behavior (UB) in C.
Issue
accept()'s third argument (addrlen) is a value-result parameter. As an input, it must be initialized to the size of the sockaddr buffer (sizeof(sin)). Passing an uninitialized int means the OS receives an indeterminate value as the buffer length. This is a latent bug that can cause accept() to fail (e.g., EINVAL) or lead to memory corruption depending on the stack state.
Suggested Fix
Initialize addr_len at declaration (or reset it before each accept() call if sin is reused):
Activity