Coverity FORWARD NULL finding in ext/Socket/Socket.c XS_Socket_inet_aton

It doesn't like this bit:

	int ok =
		(host != NULL) &&
		(*host != '\0') &&
		inet_aton(host, &ip_address);

	if (!ok && (phe = gethostbyname(host))) {

where host is set to SvPV_nolen(ST(0)).

I don't think sv_2pv_flags *can* return NULL in the first place, so
perhaps the host != NULL check should be removed.  If somehow it can
return NULL, gethostbyname shouldn't be called when host is NULL.
0
sthoenna
4/10/2006 8:51:32 AM
perl.perl5.porters 48287 articles. 1 followers. Follow

1 Replies
451 Views

Similar Articles

[PageSpeed] 10

On Mon, Apr 10, 2006 at 01:51:32AM -0700, Yitzchak Scott-Thoennes wrote:
> It doesn't like this bit:
> 
> 	int ok =
> 		(host != NULL) &&
> 		(*host != '\0') &&
> 		inet_aton(host, &ip_address);
> 
> 	if (!ok && (phe = gethostbyname(host))) {
> 
> where host is set to SvPV_nolen(ST(0)).
> 
> I don't think sv_2pv_flags *can* return NULL in the first place, so
> perhaps the host != NULL check should be removed.  If somehow it can
> return NULL, gethostbyname shouldn't be called when host is NULL.

I was going to say "in theory it could just return NULL for the case of a
messed up SV where SvPVX(sv) was 0, but SvPOK() was true" but then I looked
at the code. sv_2iv_flags, sv_2uv_flags and sv_2nv all have early returns
if it turns out that the sv in question already has the value cached in the
correct form. sv_2pv_flags doesn't. This surprised me.

I don't think that it should ever return NULL. But I think for sufficiently
malformed data, or unhelpful helper routines, it could do
(Such as get magic setting SvPOKp(sv) to true by SvPVX(sv) to NULL).

So perhaps your more defensive suggestion about checking and if so not calling
gethostbyname should be adopted.

Nicholas Clark
0
nick
4/10/2006 7:21:38 PM
Reply:

Similar Artilces:

Coverity FORWARD NULL finding in ext/IO/IO.c XS_IO__File_new_tmpfile
This is from: gv = (GV*)SvREFCNT_inc(newGVgen(packname)); hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD); where it notes that SvREFCNT_inc checks if it gets a null, so presumably gv may be null (which may be true AFAICT, at least during symbol table destruction), but any of GvSTASH, GvNAME, GvNAMELEN end up dereferencing gv. On Mon, Apr 10, 2006 at 02:20:44AM -0700, Yitzchak Scott-Thoennes wrote: > This is from: > > gv = (GV*)SvREFCNT_inc(newGVgen(packname)); > hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD); > > where it not...

ext/Socket/Socket.xs
In Socket.xs do I take it that this if (strEQ(name, "MSG_CTRUNC")) #if defined(MSG_TRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */ return MSG_CTRUNC; #else goto not_there; #endif should be MSG_CTRUNC? As in: #if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum */ Secondly, Socket.pm EXPORTs MSG_URG, but there is no code to generate it in Socket.xs. Was this an oversight somewhere? Nicholas Clark On Sun, Jun 03, 2001 at 03:03:46PM +0100, Nicholas Clark wrote: > In Socket.xs do I take it that this > > if (strEQ(...

[PATCH] Fix declaration-after-statement in ext/Socket/Socket.xs
This trivial patch lets C89-ish compilers compile Socket.c again. --- perl-current/ext/Socket/Socket.xs Thu Mar 26 20:02:08 2009 +++ perl-andy/ext/Socket/Socket.xs Thu Apr 9 10:05:26 2009 @@ -477,13 +477,14 @@ const char * host CODE: #ifdef HAS_INETPTON + int ok; struct in6_addr ip_address; if(af != AF_INET && af != AF_INET6) { croak("Bad address family for %s, got %d, should be either AF_INET or AF_INET6", "Socket::inet_pton", af); } ...

[PATCH] Whitespace fixes in ext/Socket/Socket.{pm,xs}
--tsOsTdHNUZQcU9Ye Content-Type: multipart/mixed; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The attached patch fixes whitespace in recent code added to Socket.{xs,pm} to be consistent with the rest of the files. No functionallity change. --=20 Paul "LeoNerd" Evans leonerd@leonerd.org.uk ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/ --3MwIy2ne0vdjdPXF Content-Type: text/x-di...

Socket to Socket example needed
Does anyone have any configuration examples of how to set up a socket to socket connection. I would appeciate any examples or help anyone can offer. Thanks. Rob McGinness Rutland Regional Medical Center 802-747-6526 rmcginness@rrmc.org I guess that you talk about one AIM module that drives two socket conections. If you try to build such module, you must create two protocol objects within the project. Each protocol object can control its own related objects (frame, port, open, close, etc.) > Does anyone have any configuration examples of how to set > up a socket to socke...

[PATCH] perlio.c: Coverity finding: finding false (Coverity not able to follow vtable logic) but adding an assert
--- perlio.c.dist 2006-04-08 19:09:54.000000000 +0300 +++ perlio.c 2006-04-08 19:10:16.000000000 +0300 @@ -3709,6 +3709,8 @@ if (!b->buf) PerlIO_get_base(f); /* allocate via vtable */ + assert(b->buf); + b->ptr = b->end = b->buf; if (!PerlIOValid(n)) { On Sat, Apr 08, 2006 at 07:11:36PM +0300, Jarkko Hietaniemi wrote: > --- perlio.c.dist 2006-04-08 19:09:54.000000000 +0300 > +++ perlio.c 2006-04-08 19:10:16.000000000 +0300 > @@ -3709,6 +3709,8 @@ > if (!b->buf) > PerlIO_get_base(f); /* allocate via vtable ...

[PATCH] pp_sys.c: some Coverity findings: NULL guards for format cv
--- pp_sys.c.dist 2006-04-08 18:30:22.000000000 +0300 +++ pp_sys.c 2006-04-08 18:40:08.000000000 +0300 @@ -1374,16 +1374,14 @@ gv_efullname4(sv, fgv, NULL, FALSE); name = SvPV_nolen_const(sv); if (name && *name) - DIE(aTHX_ "Undefined top format \"%s\" called",name); + DIE(aTHX_ "Undefined top format \"%s\" called", name); + else + DIE(aTHX_ "Undefined top format called"); } - /* why no: - else - DIE(aTHX_ "Undefined top format called"); - ?*/ - if (CvCLONE(cv)) + if (cv &&...

[PATCH] pp_sys.c: some Coverity findings: NULL guards for io pointers
--- pp_sys.c.dist 2006-04-08 18:30:22.000000000 +0300 +++ pp_sys.c 2006-04-08 18:40:08.000000000 +0300 @@ -2276,7 +2274,7 @@ if (!gv || !io) { if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) report_evil_fh(gv, io, PL_op->op_type); - if (IoIFP(io)) + if (io && IoIFP(io)) do_close(gv, FALSE); SETERRNO(EBADF,LIB_INVARG); RETPUSHUNDEF; @@ -2332,9 +2330,9 @@ if (!gv2 || !io2) report_evil_fh(gv1, io2, PL_op->op_type); } - if (IoIFP(io1)) + if (io1 && IoIFP(io1)) do_close(gv1, FALSE); - if (IoIFP(io2)) + if (io2 && IoIFP...

socket
perlipc doc has sample for doing a socket: use IO::Socket; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "localhost", PeerPort => "daytime(13)", ) or die "cannot connect to daytime port at localhost"; while ( <$remote> ) { print } but it dies for me. i see 'daytime' in /etc/services at port 13. osx 10.1.3 perl 5.6.1 Just because something's in services, doesn't mean it's running. Services indicates "names" for port numbers, e.g., &quo...

Segv in perly.c when running testfile ext/Socket/t/socketpair.t
I get a segv in perl pelry.c (line 201) in socketpair.t when running make test on blead. No idea whats up. Below is the stack trace (in the hope that it will be useful to someone). Cheers Yves > perl59.dll!S_clear_yystack(interpreter * my_perl=0x01a7568c, const void * p=0x01a594fc) Line 201 C perl59.dll!Perl_leave_scope(interpreter * my_perl=0x01ad6394, long base=0) Line 844 C perl59.dll!S_my_exit_jump(interpreter * my_perl=0x01a7568c) Line 5320 + 0x10 C perl59.dll!Perl_my_exit(interpreter * my_perl=0x01a7568c, unsigned long status=0) Line 5231 + 0x6 C perl5...

Socket
Dear The Expert, Where can I find complete articles for implementing windows socket in ASP.NET? TIA Winan...

socket
Hola, qualcuno sa dirmi perch�: #!/usr/bin/perl use IO::Socket; #use diagnostics; my $host=$ARGV[0]; if(!$host){ die"...host???\n"; } $|=1; $socket=IO::Socket::INET->new(PeerAddr =>$host, PeerPort=>80, Proto=>"TCP") || die"$!\n"; print $socket "GET / HTTP/1.0\r\n\r\n"; while(<$socket>){ print"$_\n"; } close($socket); FUNZIONA (scrivi e leggo dal socket),mentre al contrario: #!/usr/bin/perl use Socket; #use diagnostics; my $host=$ARGV[0]; if(!$host){ die"...host???\n"...

SOCKET
Hi all!!! Can any body help me with some information or docs about Sockets with Power Builder. I'm Working with PB 6.5, but if you have an example in PB 7 I can use it. Now I'm waiting for your help. :-) If you mean three-tier apps, pb has it's own communication objects (transport, connection). If you need something more than that you can use third-party libraries as OLE objects, because you can't work from pob directly with wsock32.dll. <CARRADINE> wrote in message news:1111D847FE7E5A290058E38C85256C75.0058E3D185256C75@webforums... > Hi all!...

Socket
How to get the ipaddress of the client machine using Socket programing,i want to check which r the pc's r connected to the server using vb.net any example will be very helpfull for me thanks in advance PrasantHI think therefore i'mvPras© If you're representing the client as a Socket, this class has a RemoteEndPoint Public property that is of type EndPoint. It encapsulates information about the client. If you're representing the client as a TcpClient, this class has a Protected Client property of type Socket (thus getting to the RemoteEndPoint). Protected meaning you have ...

Web resources about - Coverity FORWARD NULL finding in ext/Socket/Socket.c XS_Socket_inet_aton - perl.perl5.porters

Resources last updated: 2/6/2016 11:03:07 PM