CVS update: php3/functions

From: Date: Wed, 26 May 1999 13:47:14 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-6018@lists.php.net to get a copy of this message
Date: Wednesday May 26, 1999 @ 9:47 Author: sas Update of /repository/php3/functions In directory php:/tmp/cvs-serv30692 Modified Files: file.c fsock.c Log Message: - some input parameter checking - code passes all my tests now completely Index: php3/functions/file.c diff -u php3/functions/file.c:1.212 php3/functions/file.c:1.213 --- php3/functions/file.c:1.212 Wed May 26 09:08:49 1999 +++ php3/functions/file.c Wed May 26 09:47:10 1999 @@ -26,7 +26,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.212 1999/05/26 13:08:49 sas Exp $ */ +/* $Id: file.c,v 1.213 1999/05/26 13:47:10 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -790,7 +790,7 @@ buf = emalloc(sizeof(char) * (len + 1)); /* needed because recv doesnt put a null at the end*/ memset(buf,0,len+1); - if (!((issock?SOCK_FGETS(buf,len,socketd):fgets(buf,len,fp)) != NULL)) { + if ((issock?SOCK_FGETS(buf,len,socketd):fgets(buf,len,fp)) == NULL) { efree(buf); RETVAL_FALSE; } else { Index: php3/functions/fsock.c diff -u php3/functions/fsock.c:1.104 php3/functions/fsock.c:1.105 --- php3/functions/fsock.c:1.104 Wed May 26 09:08:50 1999 +++ php3/functions/fsock.c Wed May 26 09:47:11 1999 @@ -27,7 +27,7 @@ | Jim Winstead (jimw@php.net) | +----------------------------------------------------------------------+ */ -/* $Id: fsock.c,v 1.104 1999/05/26 13:08:50 sas Exp $ */ +/* $Id: fsock.c,v 1.105 1999/05/26 13:47:11 sas Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -414,12 +414,14 @@ char *_php3_sock_fgets(char *buf, size_t maxlen, int socket) { - char *p; + char *p = NULL; char *ret = NULL; size_t amount = 0; size_t nr_read; SOCK_FIND_AND_READ_MAX(1); + if(maxlen < 0) return ret; + if(sock->is_blocked) { for(nr_read = 1; !sock->eof && nr_read < maxlen; ) { nr_read += _php3_sock_read_limited(sock, 1); @@ -438,12 +440,14 @@ if(amount > 0) { memcpy(buf, READPTR(sock), amount); sock->readpos += amount; - - buf[amount] = '\0'; - - ret = buf; } + buf[amount] = '\0'; + /* signal error only, if we don't return data from this call and + if there is no data to read and if the eof flag is set */ + if(amount || TOREAD(sock) || !sock->eof) + ret = buf; + return ret; } @@ -475,6 +479,8 @@ { size_t ret = 0; SOCK_FIND_AND_READ_MAX(size); + + if(size < 0) return ret; ret = MIN(TOREAD(sock), size); if(ret) { -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6018) next »