Bug 506297 - channel_server_create() should not harcode socket address length
Summary: channel_server_create() should not harcode socket address length
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.5   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: 1.5   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-20 10:56 EDT by Jean-Michel Pedrono CLA
Modified: 2017-05-19 05:30 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Michel Pedrono CLA 2016-10-20 10:56:41 EDT
This is causing socket failure on VxWorks with latest IPNET code which now check validity of this size...

This default size should be replaced by: sizeof (struct sockaddr);


static ChannelServer * channel_server_create(PeerServer * ps, int sock) {
    ServerTCP * si = (ServerTCP *)loc_alloc_zero(sizeof *si);
    /* TODO: need to investigate usage of sizeof(sockaddr_storage) for address buffer size */
    si->addr_len = 0x1000;
Comment 1 Jean-Michel Pedrono CLA 2016-10-25 10:49:43 EDT
Hello,

I did not realize that this code has been recently changed to use SOCK_MAXADDRLEN if defined.
While this seems good, this size defined as 255 for VxWorks is still too large and does not please the latest IPNET accept() code which raise an error...
In this case, as the allocated buffer is a "struct sockaddr", I don't understand why we do not simply set si->addr_len to sizeof(sockaddr) ...

static ChannelServer * channel_server_create(PeerServer * ps, int sock) {
    ServerTCP * si = (ServerTCP *)loc_alloc_zero(sizeof *si);
    /* TODO: need to investigate usage of sizeof(sockaddr_storage) for address buffer size */
#if defined(SOCK_MAXADDRLEN)
    si->addr_len = SOCK_MAXADDRLEN;
#else
    si->addr_len = 0x1000;
#endif
    si->addr_buf = (struct sockaddr *)loc_alloc_zero(si->addr_len);

Regards,
Jean-Michel
Comment 2 Eugene Tarassov CLA 2016-10-25 13:33:16 EDT
> has been recently changed to use SOCK_MAXADDRLEN ...

The change is 5 years old

> I don't understand why we do not simply set si->addr_len to sizeof(sockaddr) 

It, probably, would not work when the channel is connected to UNIX domain socket.

I have added:

#if defined(_WRS_KERNEL)
    si->addr_len = sizeof(struct sockaddr);

Fixed.
Comment 3 Jean-Michel Pedrono CLA 2016-11-07 04:15:16 EST
Thanks!