Re: Proposed change to main.c

From: Date: Tue, 14 Dec 1999 17:50:46 +0000
Subject: Re: Proposed change to main.c
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-13695@lists.php.net to get a copy of this message
On Tue, 14 Dec 1999, Joey wrote: > void php3_log_err(char *log_message) > { > + > + int date_len = (strlen(log_message)+1) + 32; > + char date[date_len]; > + int mesg_len; > + Which compiler are you using? Declaring variables like this is bound to cause compatibility problems. emalloc() your storage instead. > FILE *log_file; > + > PLS_FETCH(); > #if APACHE > SLS_FETCH(); > #endif > > + /* Add date and time to error mesage */ > + php_error_time(date, date_len); > + mesg_len = (strlen(log_message)+strlen(date)); > + > + if ( strlcat(date, log_message, (mesg_len+1)) <= mesg_len ) > + { > + log_message = date; > + } > + 3rd argument to strlcat() should be amount of free space left, not how many characters to copy. > /* Try to use the specified logging location. */ > if (PG(error_log) != NULL) { > #if HAVE_SYSLOG_H > *************** > *** 335,340 **** > --- 350,367 ---- > #endif > } > > + php_error_time(char *buf, int len) > + { > + time_t cur_time; > + int retlen; > + > + > + /* I'm not sure /WHAT/ to do if call to time fails? */ > + time(&cur_time); > + > + retlen = strftime( buf, len, "[%a %b %d %H:%M:%S %Y] ", > localtime(&cur_time)); > + > + } Have you tested all this? You might just want to send me the corrected patch and I'll add it after review along with the .ini option that controls this behavior. -Andrei * Ethernet n.: something used to catch the etherbunny. *

« previous php.dev (#13695) next »