Changeset 2f784d7 in rtems


Ignore:
Timestamp:
Oct 8, 2018, 6:14:40 AM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
5bd75823
Parents:
be8de0ff
git-author:
Sebastian Huber <sebastian.huber@…> (10/08/18 06:14:40)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/08/18 06:15:13)
Message:

ftpd: Check return status of getsockname()

Update #3530.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ftpd/ftpd.c

    rbe8de0ff r2f784d7  
    15321532    else if (0 > listen(s, 1))
    15331533      syslog(LOG_ERR, "ftpd: Error listening on PASV socket: %s", serr());
    1534     else if(set_socket_timeout(s, info->idle))
    1535     {
    1536       char buf[FTPD_BUFSIZE];
    1537       unsigned char const *ip, *p;
    1538 
    1539       getsockname(s, (struct sockaddr *)&addr, &addrLen);
    1540       ip = (unsigned char const*)&(addr.sin_addr);
    1541       p  = (unsigned char const*)&(addr.sin_port);
    1542       snprintf(buf, FTPD_BUFSIZE, "Entering passive mode (%u,%u,%u,%u,%u,%u).",
    1543         ip[0], ip[1], ip[2], ip[3], p[0], p[1]);
    1544       send_reply(info, 227, buf);
    1545 
    1546       info->pasv_socket = accept(s, (struct sockaddr *)&addr, &addrLen);
    1547       if (0 > info->pasv_socket)
    1548         syslog(LOG_ERR, "ftpd: Error accepting PASV connection: %s", serr());
     1534    else if (set_socket_timeout(s, info->idle))
     1535    {
     1536      if (0 == getsockname(s, (struct sockaddr *)&addr, &addrLen))
     1537      {
     1538        char buf[FTPD_BUFSIZE];
     1539        unsigned char const *ip, *p;
     1540
     1541        ip = (unsigned char const*)&(addr.sin_addr);
     1542        p  = (unsigned char const*)&(addr.sin_port);
     1543        snprintf(buf, FTPD_BUFSIZE, "Entering passive mode (%u,%u,%u,%u,%u,%u).",
     1544          ip[0], ip[1], ip[2], ip[3], p[0], p[1]);
     1545        send_reply(info, 227, buf);
     1546
     1547        info->pasv_socket = accept(s, (struct sockaddr *)&addr, &addrLen);
     1548        if (0 > info->pasv_socket)
     1549          syslog(LOG_ERR, "ftpd: Error accepting PASV connection: %s", serr());
     1550        else
     1551        {
     1552          close_socket(s);
     1553          s = -1;
     1554          err = 0;
     1555        }
     1556      }
    15491557      else
    1550       {
    1551         close_socket(s);
    1552         s = -1;
    1553         err = 0;
    1554       }
     1558        syslog(LOG_ERR, "ftpd: Cannot get socket name: %s", serr());
    15551559    }
    15561560  }
Note: See TracChangeset for help on using the changeset viewer.