patacongo commented on issue #370: net: socket: Introduce net_clear_sinzero()
URL: https://github.com/apache/incubator-nuttx/pull/370#issuecomment-590859692
 
 
   > I thought it's the application's responsibility to clear sin_zero
   
   For input addresses, the form of the address parameter will be "FAR const 
struct sockaddr *addr" and the application must set the sin_zero field.  
**_These are read-only for the OS and must never be modified by the OS._**  For 
example when a struct sockaddr_in is passed to sendto().  These may not be 
written to under any circumstances (and may even lie in ROM).
   
   If Linux is modifying read-only values, it is screwed up.  We do not want 
duplicate such errors in the this OS.
   
   For output addresses, the form form of the address parameter will be "FAR 
struct sockaddr *addr).  In that case, **_the OS must also set the sin_zero 
field_** before returning,
   
   I really dislike this solution.  I think that the sin_zero field should 
always be set where ever sin_port and sin_addr is set.  You chould not have to 
check anyhting in those cases just memset() the field.  There should not be any 
centralizing logic to retroactively sets sin_zero.
   
   I am closing this PR because I think it is not correct.  It is difficult to 
understand the logic completely form just looking at the differences, and it 
may be correct if it is applied ONLY to output addresses.  However, even in 
that case.  I do not believe that it is the correct way to implement the 
zeroing.  That should be done when sin_port and sin_addr are set.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to