summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorRadu Greab <radu@netsoft.ro>2001-03-23 23:14:59 +0200
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-25 22:21:41 +0000
commitd3b9c6891b7459d54058317f1c1f213e6a01409e (patch)
tree0ea7a89f7b528ccaa07692362785f57cf64e7e8e /pp_sys.c
parent4c3ccbe1ab62eea08559462633253b2fb98ab98a (diff)
downloadperl-d3b9c6891b7459d54058317f1c1f213e6a01409e.tar.gz
Re: [ID 20010215.006] Bad arg length for Socket::unpack_sockaddr_un, length is 14 ...
Message-ID: <15035.41139.646781.478457@ix.netsoft.ro> p4raw-id: //depot/perl@9352
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/pp_sys.c b/pp_sys.c
index dc070f81b9..922fb2838e 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -98,6 +98,12 @@ extern int h_errno;
# endif
#endif
+#ifdef I_SYS_UN
+# ifdef __linux__
+# include <sys/un.h>
+# endif
+#endif
+
/* Put this after #includes because fork and vfork prototypes may conflict. */
#ifndef HAS_VFORK
# define vfork fork
@@ -1571,6 +1577,13 @@ PP(pp_sysread)
if (!(IoFLAGS(io) & IOf_UNTAINT))
SvTAINTED_on(bufsv);
SP = ORIGMARK;
+#if defined(I_SYS_UN) && defined(__linux__)
+ /* Linux returns the sum of actual pathname string length and the
+ size of the other members of sockaddr_un members. It should
+ return sizeof(struct sockaddr_un). */
+ if (((struct sockaddr *)namebuf)->sa_family == AF_UNIX)
+ bufsize = sizeof(struct sockaddr_un);
+#endif
sv_setpvn(TARG, namebuf, bufsize);
PUSHs(TARG);
RETURN;
@@ -2443,6 +2456,12 @@ PP(pp_accept)
setbuf( IoIFP(nstio), NULL); /* EPOC gets confused about sockets */
#endif
+#if defined(I_SYS_UN) && defined(__linux__)
+ /* see the comment in pp_sysread */
+ if (saddr.sa_family == AF_UNIX)
+ len = sizeof(struct sockaddr_un);
+#endif
+
PUSHp((char *)&saddr, len);
RETURN;
@@ -2620,6 +2639,11 @@ PP(pp_getpeername)
if (len == BOGUS_GETNAME_RETURN)
len = sizeof(struct sockaddr);
#endif
+#if defined(I_SYS_UN) && defined(__linux__)
+ /* see the comment in pp_sysread */
+ if (((struct sockaddr *)SvPVX(sv))->sa_family == AF_UNIX)
+ len = sizeof(struct sockaddr_un);
+#endif
SvCUR_set(sv, len);
*SvEND(sv) ='\0';
PUSHs(sv);