enw_read_tcp_message function (in TransportPdu.c) is calling the recvfrom()

Document created by cdnadmin on Jan 25, 2014
Version 1Show Document
  • View in full screen mode
This document was generated from CDN thread

Created by: Clint Cronwright on 18-07-2013 10:34:07 AM
We discovered that the enw_read_tcp_message function (in TransportPdu.c) is calling the recvfrom() function passing it the wrong parameter, three times.

The standard prototype for this function is as follows (taken from http://www.beej.us/guide/bgnet/output/html/multipage/recvman.html):

ssize_t recvfrom(int s, void *buf, size_t len, int flags,
                 struct sockaddr *from, socklen_t *fromlen);


yet, the function calls it as follows:

                bytesRecv = recvfrom (fd, &buf[bytes_read], sizeof (_powernet_secure_nw_t) - j, MYFLAG,
                                (SOCKADDR *) &from_addr, &from_addr_len);


with from_addr already defined as a pointer in the function parameter list.

                int enw_read_tcp_message(int fd, char *buf, unsigned int max_len, struct sockaddr_in *from_addr)

This results in it passing a pointer-to-a-pointer instead of the pointer as it should do.  The fix of course is to remove the & in front of from_addr in those three places. This is with Cisco-EnergyWise-Toolkit-1.2.0-RELEASE-src. A couple of questions;

Are we ok to remove the 3 & symbols or would this cause other issues?
Has this been fixed already (a newer version perhaps)?
If there is a newer version should we be using the source for that instead?

Kind regards,
Clint.

Attachments

    Outcomes