diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-04-02 01:40:29 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-04-02 01:40:29 +0200 |
commit | e8c1d0fe7cdfcbf0d913b5091a33a14da561f976 (patch) | |
tree | a04271094793b14bcd1bd5050afc7c90399b6fe7 /sys/src/ape/lib/bsd/connect.c | |
parent | e8a02760901e0b700ba845c9f57601f662e0e0aa (diff) |
ape: check *alen before copying in getpeername(), getsockname() and accept()
*alen has to be initialized to the size of the buffer
by the caller, and we are supposed to put the real
size of the address in there, but not copy more than
the original *alen value (truncate).
Diffstat (limited to 'sys/src/ape/lib/bsd/connect.c')
-rw-r--r-- | sys/src/ape/lib/bsd/connect.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/src/ape/lib/bsd/connect.c b/sys/src/ape/lib/bsd/connect.c index ebc63182a..dd6510c01 100644 --- a/sys/src/ape/lib/bsd/connect.c +++ b/sys/src/ape/lib/bsd/connect.c @@ -30,15 +30,15 @@ connect(int fd, void *a, int alen) errno = ENOTSOCK; return -1; } - if(alen > sizeof(r->raddr)){ - errno = ENAMETOOLONG; - return -1; - } sa = (struct sockaddr*)a; if(sa->sa_family != r->domain){ errno = EAFNOSUPPORT; return -1; } + if(alen > sizeof(r->raddr)){ + errno = ENAMETOOLONG; + return -1; + } memmove(&r->raddr, a, alen); switch(r->domain){ |