diff -urN thttpd-2.21-1/libhttpd.c thttpd-2.21-2/libhttpd.c --- thttpd-2.21-1/libhttpd.c Thu Nov 22 14:43:08 2001 +++ thttpd-2.21-2/libhttpd.c Thu Nov 22 14:43:09 2001 @@ -82,6 +82,50 @@ extern struct banner *bn_list; extern int vh_list_len, bn_list_len; int numreq=0; + +// KURRR!!!! GOLQM PRI TOVA +static char* tempfilename; +static int maxtempfilename = 0; + static char* header; + static int maxheader = 0; + static char* authpath; + static int maxauthpath = 0; + static char* prevauthpath; + static int maxprevauthpath = 0; + static char* prevuser; + static int maxprevuser = 0; + static char* prevcryp; + static int maxprevcryp = 0; + static char* location; + static char* header; + static int maxlocation = 0; + static char* temp; + static int maxtemp = 0; + static char* checked; + static char* rest; + static int maxchecked = 0, maxrest = 0; + static int maxnames = 0; + + static char* names; + static char** nameptrs; + static char* name; + static int maxname = 0; + static char* rname; + static int maxrname = 0; + static char* encrname; + static int maxencrname = 0; + static char* buf; + static int maxbuf = 0; + static char* indexname; + static int maxindexname = 0; + +#ifdef AUTH_FILE + static char* dirname; + static int maxdirname = 0; +#endif /* AUTH_FILE */ + static char* refhost = (char*) 0; + static int refhost_size = 0; + #endif #ifdef ADVCOUNTER #include @@ -182,8 +226,20 @@ static int my_snprintf( char* str, size_t size, const char* format, ... ); + static int reap_time; +void *rllc(void *ptr, size_t size) +{ + void *t; + t=(void *) malloc(size); + memcpy(t, ptr,sizeof(ptr)); + free(ptr); + return t; + +} + + static void child_reaper( ClientData client_data, struct timeval* nowP ) { @@ -860,8 +916,6 @@ static void send_authenticate( httpd_conn* hc, char* realm ) { - static char* header; - static int maxheader = 0; static char headstr[] = "WWW-Authenticate: Basic realm=\""; httpd_realloc_str( @@ -984,8 +1038,6 @@ static int auth_check2( httpd_conn* hc, char* dirname ) { - static char* authpath; - static int maxauthpath = 0; struct stat sb; char authinfo[500]; char* authpass; @@ -993,14 +1045,7 @@ FILE* fp; char line[500]; char* cryp; - static char* prevauthpath; - static int maxprevauthpath = 0; static time_t prevmtime; - static char* prevuser; - static int maxprevuser = 0; - static char* prevcryp; - static int maxprevcryp = 0; - /* Construct auth filename. */ httpd_realloc_str( &authpath, &maxauthpath, strlen( dirname ) + 1 + sizeof(AUTH_FILE) ); @@ -1129,9 +1174,6 @@ static void send_dirredirect( httpd_conn* hc ) { - static char* location; - static char* header; - static int maxlocation = 0, maxheader = 0; static char headstr[] = "Location: "; httpd_realloc_str( &location, &maxlocation, strlen( hc->encodedurl ) + 1 ); @@ -1223,8 +1265,6 @@ static int tilde_map_1( httpd_conn* hc ) { - static char* temp; - static int maxtemp = 0; int len; static char* prefix = TILDE_MAP_1; @@ -1246,8 +1286,10 @@ static int tilde_map_2( httpd_conn* hc ) { +#ifndef VHOST_MYSQL static char* temp; static int maxtemp = 0; +#endif static char* postfix = TILDE_MAP_2; char* cp; struct passwd* pw; @@ -1305,8 +1347,16 @@ { httpd_sockaddr sa; int sz; + /* + XXX this does not work as planned + make them global or sth like that, so they don't get fscked + up and allocated every time + shit + */ +#ifndef VHOST_MYSQL static char* tempfilename; static int maxtempfilename = 0; +#endif char* cp1; int len; #ifdef VHOST_DIRLEVELS @@ -1383,10 +1433,8 @@ } else { - httpd_realloc_str(&hc->hostdir,&maxtempfilename, - strlen(vh_list[tmp].path)); + httpd_realloc_str(&hc->hostdir,&hc->maxhostdir,strlen(vh_list[tmp].path)); (void) strcpy (hc->hostdir,vh_list[tmp].path); - maxtempfilename=0; // shit, check if file is html!!! ext=rindex(hc->origfilename,'.'); if ( ext==NULL) ext=hc->origfilename; @@ -1403,9 +1451,10 @@ (strcasecmp(ext,"txt")==0) || (strcasecmp(ext,"ico")==0) || (strcasecmp(ext,"xml")==0) || - (strcasecmp(ext,"bmp")==0) )) + (strcasecmp(ext,"bmp")==0) )) { - //deny the request + //deny the request + return 0; } @@ -1466,10 +1515,7 @@ static char* expand_symlinks( char* path, char** restP, int no_symlink, int tildemapped ) { - static char* checked; - static char* rest; char link[5000]; - static int maxchecked = 0, maxrest = 0; int checkedlen, restlen, linklen, prevcheckedlen, prevrestlen, nlinks, i; char* r; char* cp1; @@ -2606,8 +2652,10 @@ DIR* dirp; struct dirent* de; int namlen; - static int maxnames = 0; int nnames; +#ifndef VHOST_MYSQL + static int maxnames = 0; + static char* names; static char** nameptrs; static char* name; @@ -2616,6 +2664,7 @@ static int maxrname = 0; static char* encrname; static int maxencrname = 0; +#endif FILE* fp; int i, r; struct stat sb; @@ -2874,9 +2923,10 @@ { char* cp; int size; +#ifndef VHOST_MYSQL static char* buf; static int maxbuf = 0; - +#endif size = strlen( fmt ) + strlen( arg ); if ( size > maxbuf ) httpd_realloc_str( &buf, &maxbuf, size ); @@ -3439,14 +3489,17 @@ static int really_start_request( httpd_conn* hc, struct timeval* nowP ) { + static const char* index_names[] = { INDEX_NAMES }; + int i; +#ifndef VHOST_MYSQL static char* indexname; static int maxindexname = 0; - static const char* index_names[] = { INDEX_NAMES }; - int i; + #ifdef AUTH_FILE static char* dirname; static int maxdirname = 0; #endif /* AUTH_FILE */ +#endif int expnlen, indxlen; char* cp; char* pi; @@ -3873,8 +3926,10 @@ char* cp1; char* cp2; char* cp3; +#ifndef VHOST_MYSQL static char* refhost = (char*) 0; static int refhost_size = 0; +#endif char *lp; hs = hc->hs; diff -urN thttpd-2.21-1/libhttpd.h thttpd-2.21-2/libhttpd.h --- thttpd-2.21-1/libhttpd.h Thu Nov 22 14:43:08 2001 +++ thttpd-2.21-2/libhttpd.h Thu Nov 22 14:43:09 2001 @@ -46,7 +46,9 @@ #define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif #define NEW(t,n) ((t*) malloc( sizeof(t) * (n) )) -#define RENEW(o,t,n) ((t*) realloc( (void*) o, sizeof(t) * (n) )) +//#define RENEW(o,t,n) ((t*) realloc( (void*) o, sizeof(t) * (n) )) +#define RENEW(o,t,n) ((t*) rllc( (void*) o, sizeof(t) * (n) )) + /* The httpd structs. */ @@ -179,6 +181,7 @@ /* Call to shut down. */ extern void httpd_terminate( httpd_server* hs ); +void *rllc(void *ptr, size_t sz); /* When a listen fd is ready to read, call this. It does the accept() and @@ -265,3 +268,4 @@ extern void httpd_logstats( long secs ); #endif /* _LIBHTTPD_H_ */ +