From 860e177e53eed8ab184e35cdc25b2c35936e9b2f Mon Sep 17 00:00:00 2001 From: Mark Janssen Date: Sat, 11 Feb 2006 00:21:16 +0000 Subject: [PATCH] Cleanup setproctitle, changed return-type of readline() git-svn-id: https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/trunk/proxytunnel@111 bc163920-b10d-0410-b2c5-a5491ca2ceef --- Makefile | 4 ++-- http.c | 9 +++++++-- io.c | 3 ++- io.h | 2 +- proxytunnel.c | 2 +- setproctitle.c | 6 +++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 1794cf8..c5c0d87 100755 --- a/Makefile +++ b/Makefile @@ -3,9 +3,9 @@ # Please uncomment the appropriate settings CC ?= gcc -CFLAGS ?= -Wall -O2 +CFLAGS ?= -Wall -O2 -g CFLAGS += -DHAVE_GETOPT_LONG -DUSE_SSL -#CFLAGS += -DSETPROCTITLE +CFLAGS += -DSETPROCTITLE -DSPT_TYPE=1 LDFLAGS += -lssl PREFIX =/usr/local diff --git a/http.c b/http.c index dba17e1..2d97498 100644 --- a/http.c +++ b/http.c @@ -45,8 +45,13 @@ void analyze_HTTP() */ while (strncmp( p, "HTTP/", 5) != 0 ) { - readline(); - p = strtok( buf, " "); + if ( readline() ) + p = strtok( buf, " "); + else + { + message( "analyze_HTTP: borken\n" ); + break; + } } if (strcmp( p, "HTTP/1.0" ) != 0 && strcmp( p, "HTTP/1.1" ) != 0) diff --git a/io.c b/io.c index 0c83d29..6d1fe6d 100644 --- a/io.c +++ b/io.c @@ -41,7 +41,7 @@ * Read one line of data from the tunnel. Line is terminated by a * newline character. Result is stored in buf. */ -void readline() +int readline() { char *p = buf; char c = 0; @@ -68,6 +68,7 @@ void readline() if( args_info.verbose_flag ) message( "DEBUG: recv: '%s'", buf ); + return strlen( buf ); } /* diff --git a/io.h b/io.h index 469f5ce..128cd5a 100644 --- a/io.h +++ b/io.h @@ -18,7 +18,7 @@ */ /* io.h */ -void readline(); +int readline(); int copy(int from, int to); void cpio(); diff --git a/proxytunnel.c b/proxytunnel.c index 0d4490d..e32fda9 100755 --- a/proxytunnel.c +++ b/proxytunnel.c @@ -355,7 +355,7 @@ int main( int argc, char *argv[], char *envp[] ) #endif #ifdef SETPROCTITLE if( args_info.proctitle_given ) - setproctitle( args_info.proctitle_arg ); + setproctitle( "%s\0", args_info.proctitle_arg ); #else if( args_info.proctitle_given ) message( "Setting process-title is not supported in this build\n"); diff --git a/setproctitle.c b/setproctitle.c index e6eccf3..1c285ca 100644 --- a/setproctitle.c +++ b/setproctitle.c @@ -74,10 +74,10 @@ #define SPT_SCO 6 /* write kernel u. area */ #define SPT_CHANGEARGV 7 /* write our own strings into argv[] */ -# define MAXLINE 2048 /* max line length */ +#define MAXLINE 2048 /* max line length */ #ifndef SPT_TYPE -# define SPT_TYPE SPT_REUSEARGV +# define SPT_TYPE SPT_NONE #endif #if SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN @@ -121,7 +121,7 @@ typedef unsigned int *pt_entry_t; # endif # ifndef SPT_PADCHAR -# define SPT_PADCHAR ' ' +# define SPT_PADCHAR '\0' # endif # ifndef SPT_BUFSIZE