Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18c9a4f

Browse files
committed
* socketmodule.c: fix long-standing bug in recvfrom() -- addrlen
wasn't initialized.
1 parent 66338ec commit 18c9a4f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Modules/socketmodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ This module provides an interface to Berkeley socket IPC.
3232
- only AF_INET and AF_UNIX address families are supported
3333
- no asynchronous I/O (but read polling: avail)
3434
- no read/write operations (use send/recv or makefile instead)
35-
- no flags on recvfrom operations
3635
- setsockopt() and getsockopt() only support integer options
3736
3837
Interface:
@@ -62,7 +61,7 @@ Socket methods:
6261
- s.listen(n) --> None
6362
- s.makefile(mode) --> file object
6463
- s.recv(nbytes [,flags]) --> string
65-
- s.recvfrom(nbytes) --> string, sockaddr
64+
- s.recvfrom(nbytes [,flags]) --> string, sockaddr
6665
- s.send(string [,flags]) --> None
6766
- s.sendto(string, [flags,] sockaddr) --> None
6867
- s.shutdown(how) --> None
@@ -714,7 +713,11 @@ sock_recvfrom(s, args)
714713
if (!getargs(args, "(ii)", &len, &flags))
715714
return NULL;
716715
}
716+
if (!getsockaddrlen(s, &addrlen))
717+
return NULL;
717718
buf = newsizedstringobject((char *) 0, len);
719+
if (buf == NULL)
720+
return NULL;
718721
BGN_SAVE
719722
n = recvfrom(s->sock_fd, getstringvalue(buf), len, flags,
720723
addrbuf, &addrlen);

0 commit comments

Comments
 (0)