Mercurial > noffle
diff src/protocol.c @ 250:93d5d8b098da noffle
[svn] *** empty log message ***
author | mirkol |
---|---|
date | Wed, 05 Jun 2002 23:03:44 +0100 |
parents | 0340b9c17edc |
children | 030c41dfd9ba |
line wrap: on
line diff
--- a/src/protocol.c Tue May 14 15:25:45 2002 +0100 +++ b/src/protocol.c Wed Jun 05 23:03:44 2002 +0100 @@ -1,7 +1,7 @@ /* protocol.c - $Id: protocol.c 381 2002-05-14 14:25:45Z mirkol $ + $Id: protocol.c 382 2002-06-05 22:03:44Z mirkol $ */ #if HAVE_CONFIG_H @@ -37,6 +37,7 @@ size_t len; char *ret; sig_t oldHandler = NULL; + int line_too_long; if ( timeoutSeconds >= 0 ) { @@ -62,11 +63,33 @@ if ( ret == NULL ) return FALSE; len = strlen( line ); - if ( len > 0 && line[ len - 1 ] == '\n' ) + if ( len > 0 ) { - line[ len - 1 ] = '\0'; - if ( len > 1 && line[ len - 2 ] == '\r' ) - line[ len - 2 ] = '\0'; + if ( line[ len - 1 ] == '\n' ) + { + line[ len - 1 ] = '\0'; + if ( len > 1 && line[ len - 2 ] == '\r' ) + line[ len - 2 ] = '\0'; + } + else + { + /* line too long, skip the rest */ + if( len == MAXCHAR ) + { + Log_err( "Line too long:" ); + do + { + line_too_long = fgetc( f ); + } + while( line_too_long == EOF || line_too_long == '\n' ); + } + else + /* EOF occured in line, skip line. */ + { + Log_err( "Ignoring incomplete line %s", line); + return FALSE; + } + } } Log_dbg( LOG_DBG_PROTOCOL, "[R] %s", line ); return TRUE;