summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-10-31 12:44:39 +0000
committerDavid Mitchell <davem@iabyn.com>2010-10-31 13:04:03 +0000
commit8eb023a9cc1ea46c4dc9b9bb6dd651817ac32889 (patch)
tree291f6c555c2139af350c58b8bdfb6bedf5a8059a /pp_sys.c
parente97701b4b83f1279df76a98fe4d520e07dd60c99 (diff)
downloadperl-8eb023a9cc1ea46c4dc9b9bb6dd651817ac32889.tar.gz
RT 75082: recv() with MSG_TRUNC flag SEGV
The recv() system call, with the MSG_TRUNC flag, returns the true size of the packet, even if it is larger than the supplied buffer. Since perl's equivalent recv() function doesn't return the size (apart from what's implied as the returned length of the buffer), there doesn't seem to to be any way to return this value to the caller. So silently ignore it. Before, we were setting SvCUR to the size, even if it was larger than the buffer. Which was Bad.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 2497ec2ce1..c3d0505833 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1655,6 +1655,9 @@ PP(pp_sysread)
(struct sockaddr *)namebuf, &bufsize);
if (count < 0)
RETPUSHUNDEF;
+ /* MSG_TRUNC can give oversized count; quietly lose it */
+ if (count > length)
+ count = length;
#ifdef EPOC
/* Bogus return without padding */
bufsize = sizeof (struct sockaddr_in);