Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix Domain sockaddr returned by recv is not acceptable to Socket::unpack_sockaddr_un #1098

Closed
p5pRT opened this issue Jan 27, 2000 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 27, 2000

Migrated from rt.perl.org#2052 (status was 'resolved')

Searchable as RT2052$

@p5pRT
Copy link
Author

p5pRT commented Jan 27, 2000

From oloryn@www.mindspring.com

Run this perl program​:

-----
#!/usr/bin/perl -w

use Socket;

socket(SERVER, AF_UNIX, SOCK_DGRAM, 0);
bind(SERVER, pack_sockaddr_un('/tmp/server'));

$sock_addr = recv(SERVER, $message, 256, 0);
$sock_path = unpack_sockaddr_un($sock_addr);
print "$sock_path\n";
print "$message\n";
-----

and then run this one to send a message to the first​:

-----
#!/usr/bin/perl -w

use Socket;

socket(CLIENT, AF_UNIX, SOCK_DGRAM, 0);
bind(CLIENT, pack_sockaddr_un('/tmp/client'));

send(CLIENT, 'Test message', 0, pack_sockaddr_un('/tmp/server'));
-----

and the first will die with the message

Bad arg length for Socket​::unpack_sockaddr_un, length is 14, should be 110 at udtest.srv line 9.

If Socket​::unpack_sockaddr_un is going to expect a 110-byte long Unix Domain
sockaddr, shouldn't recv be returning one? Either Socket​::unpack_sockaddr_un
or recv needs to be fixed.

Perl Info


Site configuration information for perl 5.00503:

Configured by root at Sun Jul 18 14:58:08 CDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.6, archname=i386-linux
    uname='linux xyzzy 2.2.6 #2 wed jun 16 15:23:52 cdt 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /shlib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/i386-linux
    /usr/lib/perl5
    /usr/lib/perl5/site_perl/i386-linux
    /usr/lib/perl5/site_perl
    .


Environment for perl 5.00503:
    HOME=/home/oloryn
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/oloryn/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/openwin/bin:/usr/games:.:/usr/share/texmf/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2008

From renee.baecker@smart-websolutions.de

Tested with Perl 5.8.8 and Perl 5.10

reneeb@​reneeb-desktop​:~/bugs$ perl 2052.pl
/tmp/client
Test message
reneeb@​reneeb-desktop​:~/bugs$ /opt/perl510/bin/perl 2052.pl
/tmp/client
Test message
reneeb@​reneeb-desktop​:~/bugs$

Cheers,
Renee

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2008

@rgs - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 15, 2008
@p5pRT
Copy link
Author

p5pRT commented Aug 10, 2008

From p5p@spam.wizbit.be

This was fixed between perl-5.6.0 and perl-5.6.1 with Change 9352.

http​://public.activestate.com/cgi-bin/perlbrowse/p/9352
Change 9352 by jhi@​alpha on 2001/03/25 22​:21​:41

  Subject​: Re​: [ID 20010215.006] Bad arg length for
Socket​::unpack_sockaddr_un, length is 14 ...
  From​: Radu Greab <radu@​netsoft.ro>
  Date​: Fri, 23 Mar 2001 21​:14​:59 +0200 (EET)
  Message-ID​: <15035.41139.646781.478457@​ix.netsoft.ro>

----Program----
#!/usr/bin/perl -w

use Socket;

unlink "/tmp/server";
unlink "/tmp/client";

socket(SERVER, AF_UNIX, SOCK_DGRAM, 0);
bind(SERVER, pack_sockaddr_un('/tmp/server'));

socket(CLIENT, AF_UNIX, SOCK_DGRAM, 0);
bind(CLIENT, pack_sockaddr_un('/tmp/client'));

send(CLIENT, 'Test message', 0, pack_sockaddr_un('/tmp/server'));

$sock_addr = recv(SERVER, $message, 256, 0);
$sock_path = unpack_sockaddr_un($sock_addr);
print "$sock_path\n";
print "$message\n";

----Output of ...l/ptL6T6c/perl-5.7.0@​9344/bin/perl----
Bad arg length for Socket​::unpack_sockaddr_un, length is 14, should be
110 at rt-2052.pl line 18.

----EOF ($?='65280')----
----Output of ...l/p1qce8k/perl-5.7.0@​9352/bin/perl----
/tmp/client
Test message

----EOF ($?='0')----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant