From: tausq <> Date: Mon, 21 Feb 2000 05:08:32 +0000 (+0000) Subject: (hopefully) fixed error checking so it won't infinite loop X-Git-Tag: debian_userdir-ldap_0-3-7~168 X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;ds=sidebyside;h=fa73c960b402b9fdf77b8d7db5653231dbf8a887;p=mirror%2Fuserdir-ldap.git (hopefully) fixed error checking so it won't infinite loop --- diff --git a/ud-fingerserv b/ud-fingerserv index 7f33835..17c64a7 100755 --- a/ud-fingerserv +++ b/ud-fingerserv @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: ud-fingerserv,v 1.13 1999/11/29 02:44:53 tausq Exp $ +# $Id: ud-fingerserv,v 1.14 2000/02/21 06:08:32 tausq Exp $ # (c) 1999 Randolph Chung. Licensed under the GPL. @@ -66,7 +66,7 @@ if (!$use_inetd) { my $hostinfo = gethostbyaddr($client->peeraddr, AF_INET); &log(sprintf("[Connect from %s]", $hostinfo || $client->peerhost)); my $query = &readdata($client); - &ProcessQuery($client, $query); + &ProcessQuery($client, $query) if (defined($query)); $client->close; exit; } continue { @@ -78,7 +78,7 @@ if (!$use_inetd) { my ($port, $addr) = unpack_sockaddr_in(getpeername(STDIN)); &log(sprintf("[Connect from %s (%s)]", gethostbyaddr($addr, AF_INET), inet_ntoa($addr))); my $query = &readdata(\*STDIN); - &ProcessQuery(\*STDOUT, $query); + &ProcessQuery(\*STDOUT, $query) if (defined($query)); exit; } @@ -175,6 +175,7 @@ sub readdata { my $in = undef; my $out = undef; my $bytesread = 0; + my $ret; my $flags= fcntl($fh, F_GETFL, 0) or die "Can't get flags for socket: $!\n"; @@ -182,7 +183,9 @@ sub readdata { or die "Can't make socket nonblocking: $!\n"; while (($bytesread < 1024) && ($out !~ /\n/)) { - $bytesread += sysread($fh, $in, 1024); + $ret = sysread($fh, $in, 1024); + return undef if (!defined($ret) || ($ret == 0)); + $bytesread += $ret; $out .= $in; }