From 18c9a4f8ea85f95ba5623fc2c090bc11bae675d9 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 25 May 1993 12:16:29 +0000 Subject: * socketmodule.c: fix long-standing bug in recvfrom() -- addrlen wasn't initialized. --- Modules/socketmodule.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 503a359..160c292 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -32,7 +32,6 @@ Limitations: - only AF_INET and AF_UNIX address families are supported - no asynchronous I/O (but read polling: avail) - no read/write operations (use send/recv or makefile instead) -- no flags on recvfrom operations - setsockopt() and getsockopt() only support integer options Interface: @@ -62,7 +61,7 @@ Socket methods: - s.listen(n) --> None - s.makefile(mode) --> file object - s.recv(nbytes [,flags]) --> string -- s.recvfrom(nbytes) --> string, sockaddr +- s.recvfrom(nbytes [,flags]) --> string, sockaddr - s.send(string [,flags]) --> None - s.sendto(string, [flags,] sockaddr) --> None - s.shutdown(how) --> None @@ -714,7 +713,11 @@ sock_recvfrom(s, args) if (!getargs(args, "(ii)", &len, &flags)) return NULL; } + if (!getsockaddrlen(s, &addrlen)) + return NULL; buf = newsizedstringobject((char *) 0, len); + if (buf == NULL) + return NULL; BGN_SAVE n = recvfrom(s->sock_fd, getstringvalue(buf), len, flags, addrbuf, &addrlen); -- cgit v0.12