Changeset 2516


Ignore:
Timestamp:
Feb 4, 2006, 1:26:03 PM (20 years ago)
Author:
bird
Message:

#25: Ensure correct address length returns from recvmsg and recvfrom.

Location:
branches/libc-0.6/src/emx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2515 r2516  
    44
    552006-02-04: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     6    - libsocket:
     7        o #25: Ensure correct address length returns from recvmsg and recvfrom.
    68    - libc:
    79        o #32: Fixed incorrect readdir_r return code when out of files.
  • branches/libc-0.6/src/emx/src/libsocket/recvfrom.c

    r1517 r2516  
    3030#include "libc-alias.h"
    3131#include <errno.h>
     32#include <netinet/in.h>
    3233#include <sys/socket.h>
    3334#include <sys/fcntl.h>
     
    4748        rc = __libsocket_recvfrom(pFHSocket->iSocket, buf, len, flags, from, fromlen);
    4849        if (rc >= 0)
     50        {
     51            if (from && fromlen)
     52            {
     53#ifdef TCPV40HDRS
     54                if (*fromlen > sizeof(struct sockaddr_in) && from->sa_family == AF_INET)
     55                    *fromlen = sizeof(struct sockaddr_in);
     56#else
     57                if (*fromlen > from->sa_len)
     58                    *fromlen = from->sa_len;
     59#endif
     60            }
    4961            LIBCLOG_RETURN_INT(rc);
     62        }
    5063        __libc_TcpipUpdateErrno();
    5164    }
  • branches/libc-0.6/src/emx/src/libsocket/recvmsg.c

    r1454 r2516  
    3131#include <errno.h>
    3232#include <sys/socket.h>
     33#include <netinet/in.h>
    3334#include <sys/fcntl.h>
    3435#include <emx/io.h>
     
    4647        rc = __libsocket_recvmsg(pFHSocket->iSocket, msg, flags);
    4748        if (rc >= 0)
     49        {
     50            /* Workaround for missing msg_namelen update. Required if a IPV6 sized buffer is given.
     51             * (This problem hasn't been explored well enough, so this workaround is rather cautious.)
     52             */
     53            if (msg)
     54            {
     55                struct sockaddr_in *pAddr = (struct sockaddr_in *)msg->msg_name;
     56#ifndef TCPV40HDRS
     57                if (pAddr && msg->msg_namelen > pAddr->sin_len)
     58                    msg->msg_namelen = pAddr->sin_len;
     59#else
     60
     61                if (    pAddr
     62                    &&  pAddr->sin_family == AF_INET
     63                    &&  msg->msg_namelen > sizeof(struct sockaddr_in))
     64                    msg->msg_namelen = sizeof(struct sockaddr_in);
     65#endif
     66
     67            }
    4868            LIBCLOG_RETURN_INT(rc);
     69        }
    4970        __libc_TcpipUpdateErrno();
    5071    }
Note: See TracChangeset for help on using the changeset viewer.