diff --git a/config/axhttpd.aip b/config/axhttpd.aip index 2bac4caa6..5d1a2254f 100755 --- a/config/axhttpd.aip +++ b/config/axhttpd.aip @@ -1,5 +1,5 @@ - + @@ -8,10 +8,10 @@ - + - + @@ -30,51 +30,47 @@ - - - - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,13 +101,14 @@ + - + @@ -127,12 +124,6 @@ - - - - - - diff --git a/config/makefile.conf b/config/makefile.conf index 4255dbe46..aff790995 100644 --- a/config/makefile.conf +++ b/config/makefile.conf @@ -57,8 +57,8 @@ endif CC=cl.exe LD=link.exe AXTLS_INCLUDE=$(shell cygpath -w $(AXTLS_HOME)) -CFLAGS+=/nologo /W3 /D "WIN32" /D "_MBCS" /D "_CONSOLE" /FD /I"$(AXTLS_INCLUDE)crypto" /I"$(AXTLS_INCLUDE)ssl" /I"$(AXTLS_INCLUDE)config" /c -LDFLAGS=/nologo /subsystem:console /machine:I386 +CFLAGS+=/nologo /W3 /D"WIN32" /D"_MBCS" /D"_CONSOLE" /D"_CRT_SECURE_NO_DEPRECATE" /FD /I"$(AXTLS_INCLUDE)crypto" /I"$(AXTLS_INCLUDE)ssl" /I"$(AXTLS_INCLUDE)config" /c +LDFLAGS=/nologo /subsystem:console /machine:I386 Advapi32.lib LDSHARED = /dll AR=lib /nologo diff --git a/config/win32config b/config/win32config index 3e0b4223c..be5ac45f8 100644 --- a/config/win32config +++ b/config/win32config @@ -1,125 +1,120 @@ -# -# Automatically generated make config: don't edit -# -HAVE_DOT_CONFIG=y -# CONFIG_PLATFORM_LINUX is not set -# CONFIG_PLATFORM_CYGWIN is not set -# CONFIG_PLATFORM_SOLARIS is not set -CONFIG_PLATFORM_WIN32=y - -# -# General Configuration -# -PREFIX="" -# CONFIG_DEBUG is not set - -# -# Microsoft Compiler Options -# -# CONFIG_VISUAL_STUDIO_6_0 is not set -CONFIG_VISUAL_STUDIO_7_0=y -# CONFIG_VISUAL_STUDIO_8_0 is not set -CONFIG_VISUAL_STUDIO_6_0_BASE="" -CONFIG_VISUAL_STUDIO_7_0_BASE="c:\\Program Files\\Microsoft Visual Studio .NET 2003" -CONFIG_VISUAL_STUDIO_8_0_BASE="" -CONFIG_EXTRA_CFLAGS_OPTIONS="" -CONFIG_EXTRA_LDFLAGS_OPTIONS="" - -# -# SSL Library -# -# CONFIG_SSL_SERVER_ONLY is not set -# CONFIG_SSL_CERT_VERIFICATION is not set -# CONFIG_SSL_ENABLE_CLIENT is not set -CONFIG_SSL_FULL_MODE=y -# CONFIG_SSL_SKELETON_MODE is not set -# CONFIG_SSL_PROT_LOW is not set -CONFIG_SSL_PROT_MEDIUM=y -# CONFIG_SSL_PROT_HIGH is not set -CONFIG_SSL_USE_DEFAULT_KEY=y -CONFIG_SSL_ENABLE_V23_HANDSHAKE=y -CONFIG_SSL_HAS_PEM=y -CONFIG_SSL_USE_PKCS12=y -CONFIG_SSL_EXPIRY_TIME=24 -CONFIG_X509_MAX_CA_CERTS=4 -CONFIG_SSL_MAX_CERTS=2 -# CONFIG_SSL_CTX_MUTEXING is not set -# CONFIG_USE_DEV_URANDOM is not set -CONFIG_WIN32_USE_CRYPTO_LIB=y -# CONFIG_OPENSSL_COMPATIBLE is not set -# CONFIG_PERFORMANCE_TESTING is not set -# CONFIG_SSL_TEST is not set -CONFIG_AXHTTPD=y - -# -# Axhttpd Configuration -# -# CONFIG_HTTP_STATIC_BUILD is not set -CONFIG_HTTP_PORT=80 -CONFIG_HTTP_HTTPS_PORT=443 -CONFIG_HTTP_SESSION_CACHE_SIZE=5 -CONFIG_HTTP_WEBROOT="../www" -CONFIG_HTTP_TIMEOUT=300 - -# -# CGI -# -# CONFIG_HTTP_HAS_CGI is not set -CONFIG_HTTP_CGI_EXTENSIONS="" -# CONFIG_HTTP_ENABLE_LUA is not set -CONFIG_HTTP_LUA_PREFIX="" -# CONFIG_HTTP_BUILD_LUA is not set -CONFIG_HTTP_DIRECTORIES=y -CONFIG_HTTP_HAS_AUTHORIZATION=y -# CONFIG_HTTP_USE_CHROOT is not set -# CONFIG_HTTP_CHANGE_UID is not set -# CONFIG_HTTP_HAS_IPV6 is not set -# CONFIG_HTTP_VERBOSE is not set -# CONFIG_HTTP_IS_DAEMON is not set - -# -# Language Bindings -# -CONFIG_BINDINGS=y -CONFIG_CSHARP_BINDINGS=y -CONFIG_VBNET_BINDINGS=y - -# -# .Net Framework -# -CONFIG_DOT_NET_FRAMEWORK_BASE="c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727" -CONFIG_JAVA_BINDINGS=y - -# -# Java Home -# -CONFIG_JAVA_HOME="c:\\Program Files\\Java\\jdk1.5.0_06" -# CONFIG_PERL_BINDINGS is not set -CONFIG_PERL_CORE="" -CONFIG_PERL_LIB="" -# CONFIG_LUA_BINDINGS is not set -CONFIG_LUA_CORE="" - -# -# Samples -# -CONFIG_SAMPLES=y -CONFIG_C_SAMPLES=y -CONFIG_CSHARP_SAMPLES=y -CONFIG_VBNET_SAMPLES=y -CONFIG_JAVA_SAMPLES=y -# CONFIG_PERL_SAMPLES is not set - -# -# BigInt Options -# -# CONFIG_BIGINT_CLASSICAL is not set -# CONFIG_BIGINT_MONTGOMERY is not set -CONFIG_BIGINT_BARRETT=y -CONFIG_BIGINT_CRT=y -# CONFIG_BIGINT_KARATSUBA is not set -MUL_KARATSUBA_THRESH=0 -SQU_KARATSUBA_THRESH=0 -CONFIG_BIGINT_SLIDING_WINDOW=y -CONFIG_BIGINT_SQUARE=y -# CONFIG_BIGINT_CHECK_ON is not set +# +# Automatically generated make config: don't edit +# +HAVE_DOT_CONFIG=y +# CONFIG_PLATFORM_LINUX is not set +# CONFIG_PLATFORM_CYGWIN is not set +# CONFIG_PLATFORM_SOLARIS is not set +CONFIG_PLATFORM_WIN32=y + +# +# General Configuration +# +PREFIX="" +# CONFIG_DEBUG is not set +# CONFIG_STRIP_UNWANTED_SECTIONS is not set + +# +# Microsoft Compiler Options +# +# CONFIG_VISUAL_STUDIO_6_0 is not set +# CONFIG_VISUAL_STUDIO_7_0 is not set +CONFIG_VISUAL_STUDIO_8_0=y +CONFIG_VISUAL_STUDIO_6_0_BASE="" +CONFIG_VISUAL_STUDIO_7_0_BASE="" +CONFIG_VISUAL_STUDIO_8_0_BASE="c:\\Program Files\\Microsoft Visual Studio 8" +CONFIG_EXTRA_CFLAGS_OPTIONS="" +CONFIG_EXTRA_LDFLAGS_OPTIONS="" + +# +# SSL Library +# +# CONFIG_SSL_SERVER_ONLY is not set +# CONFIG_SSL_CERT_VERIFICATION is not set +# CONFIG_SSL_ENABLE_CLIENT is not set +CONFIG_SSL_FULL_MODE=y +# CONFIG_SSL_SKELETON_MODE is not set +# CONFIG_SSL_PROT_LOW is not set +CONFIG_SSL_PROT_MEDIUM=y +# CONFIG_SSL_PROT_HIGH is not set +CONFIG_SSL_USE_DEFAULT_KEY=y +CONFIG_SSL_ENABLE_V23_HANDSHAKE=y +CONFIG_SSL_HAS_PEM=y +CONFIG_SSL_USE_PKCS12=y +CONFIG_SSL_EXPIRY_TIME=24 +CONFIG_X509_MAX_CA_CERTS=4 +CONFIG_SSL_MAX_CERTS=2 +# CONFIG_SSL_CTX_MUTEXING is not set +# CONFIG_USE_DEV_URANDOM is not set +CONFIG_WIN32_USE_CRYPTO_LIB=y +# CONFIG_OPENSSL_COMPATIBLE is not set +# CONFIG_PERFORMANCE_TESTING is not set +# CONFIG_SSL_TEST is not set +CONFIG_AXHTTPD=y + +# +# Axhttpd Configuration +# +# CONFIG_HTTP_STATIC_BUILD is not set +CONFIG_HTTP_PORT=80 +CONFIG_HTTP_HTTPS_PORT=443 +CONFIG_HTTP_SESSION_CACHE_SIZE=5 +CONFIG_HTTP_WEBROOT="www" +CONFIG_HTTP_TIMEOUT=300 + +# +# CGI +# +# CONFIG_HTTP_HAS_CGI is not set +CONFIG_HTTP_CGI_EXTENSIONS="" +# CONFIG_HTTP_ENABLE_LUA is not set +CONFIG_HTTP_LUA_PREFIX="" +CONFIG_HTTP_LUA_CGI_LAUNCHER="" +# CONFIG_HTTP_BUILD_LUA is not set +CONFIG_HTTP_DIRECTORIES=y +CONFIG_HTTP_HAS_AUTHORIZATION=y +# CONFIG_HTTP_USE_CHROOT is not set +# CONFIG_HTTP_CHANGE_UID is not set +# CONFIG_HTTP_HAS_IPV6 is not set +CONFIG_HTTP_VERBOSE=y +# CONFIG_HTTP_IS_DAEMON is not set + +# +# Language Bindings +# +# CONFIG_BINDINGS is not set +# CONFIG_CSHARP_BINDINGS is not set +# CONFIG_VBNET_BINDINGS is not set +CONFIG_DOT_NET_FRAMEWORK_BASE="" +# CONFIG_JAVA_BINDINGS is not set +CONFIG_JAVA_HOME="" +# CONFIG_PERL_BINDINGS is not set +CONFIG_PERL_CORE="" +CONFIG_PERL_LIB="" +# CONFIG_LUA_BINDINGS is not set +CONFIG_LUA_CORE="" + +# +# Samples +# +CONFIG_SAMPLES=y +CONFIG_C_SAMPLES=y +# CONFIG_CSHARP_SAMPLES is not set +# CONFIG_VBNET_SAMPLES is not set +# CONFIG_JAVA_SAMPLES is not set +# CONFIG_PERL_SAMPLES is not set +# CONFIG_LUA_SAMPLES is not set + +# +# BigInt Options +# +# CONFIG_BIGINT_CLASSICAL is not set +# CONFIG_BIGINT_MONTGOMERY is not set +CONFIG_BIGINT_BARRETT=y +CONFIG_BIGINT_CRT=y +# CONFIG_BIGINT_KARATSUBA is not set +MUL_KARATSUBA_THRESH=0 +SQU_KARATSUBA_THRESH=0 +CONFIG_BIGINT_SLIDING_WINDOW=y +CONFIG_BIGINT_SQUARE=y +# CONFIG_BIGINT_CHECK_ON is not set diff --git a/httpd/axhttp.h b/httpd/axhttp.h index 439fd9127..2da364e74 100644 --- a/httpd/axhttp.h +++ b/httpd/axhttp.h @@ -129,7 +129,9 @@ void procreadhead(struct connstruct *cn); void procsendhead(struct connstruct *cn); void procreadfile(struct connstruct *cn); void procsendfile(struct connstruct *cn); +#if defined(CONFIG_HTTP_HAS_CGI) void read_post_data(struct connstruct *cn); +#endif /* misc.c prototypes */ char *my_strncpy(char *dest, const char *src, size_t n); diff --git a/httpd/axhttpd.c b/httpd/axhttpd.c index 2f5fd19bf..701d58853 100644 --- a/httpd/axhttpd.c +++ b/httpd/axhttpd.c @@ -301,10 +301,12 @@ int main(int argc, char *argv[]) FD_ISSET(to->networkdesc, &rfds)) { active--; - if (to->post_state) - read_post_data(to); - else - procreadhead(to); +#if defined(CONFIG_HTTP_HAS_CGI) + if (to->post_state) + read_post_data(to); + else +#endif + procreadhead(to); } if (to->state == STATE_WANT_TO_SEND_HEAD && diff --git a/httpd/proc.c b/httpd/proc.c index bb50b5a24..35388e7fc 100644 --- a/httpd/proc.c +++ b/httpd/proc.c @@ -49,6 +49,7 @@ static void procdirlisting(struct connstruct *cn); #if defined(CONFIG_HTTP_HAS_CGI) static void proccgi(struct connstruct *cn); static void decode_path_info(struct connstruct *cn, char *path_info); +static int init_read_post_data(char *buf, char *data, struct connstruct *cn, int old_rv); #endif #ifdef CONFIG_HTTP_HAS_AUTHORIZATION static int auth_check(struct connstruct *cn); @@ -281,113 +282,12 @@ static void urlencode(const uint8_t *s, char *t) #endif -int init_read_post_data(char *buf, char *data, struct connstruct *cn, int old_rv) -{ - char *next; - int rv; - char *post_data; - - rv=old_rv; - next=data; - - /* Too much Post data to send. MAXPOSTDATASIZE should be - configured (now it can be chaged in the header file) */ - if (cn->content_length > MAXPOSTDATASIZE) - { - send_error(cn, 418); - return 0; - } - - /* remove CRLF */ - while ((*next == '\r' || *next == '\n') && (next < &buf[rv])) - next++; - - if (cn->post_data == NULL) - { - cn->post_data = (char *) calloc(1, (cn->content_length + 1)); - /* Allocate buffer for the POST data that will be used by proccgi - to send POST data to the CGI script */ - - if (cn->post_data == NULL) - { - printf("axhttpd: could not allocate memory for POST data\n"); - TTY_FLUSH(); - send_error(cn, 599); - return 0; - } - } - - cn->post_state = 0; - cn->post_read = 0; - post_data = cn->post_data; - - while (next < &buf[rv]) - { - /*copy POST data to buffer*/ - *post_data = *next; - post_data++; - next++; - cn->post_read++; - if (cn->post_read == cn->content_length) - { - /* No more POST data to be copied */ - *post_data = '\0'; - return 1; - } - } - - /* More POST data has to be read. read_post_data will continue with that */ - cn->post_state = 1; - return 0; -} - -void read_post_data(struct connstruct *cn) -{ - char buf[MAXREQUESTLENGTH*4], *next; - char *post_data; - int rv; - - bzero(buf,MAXREQUESTLENGTH*4); - rv = special_read(cn, buf, sizeof(buf)-1); - if (rv <= 0) - { - if (rv < 0) /* really dead? */ - removeconnection(cn); - return; - } - - buf[rv] = '\0'; - next = buf; - - post_data = &cn->post_data[cn->post_read]; - - while (next < &buf[rv]) - { - *post_data = *next; - post_data++; - next++; - cn->post_read++; - if (cn->post_read == cn->content_length) - { - /* No more POST data to be copied */ - *post_data='\0'; - cn->post_state = 0; - buildactualfile(cn); - cn->state = STATE_WANT_TO_SEND_HEAD; - return; - } - } - - /* More POST data to read */ -} - - void procreadhead(struct connstruct *cn) { char buf[MAXREQUESTLENGTH*4], *tp, *next; int rv; - bzero(buf,MAXREQUESTLENGTH*4); + memset(buf, 0, MAXREQUESTLENGTH*4); rv = special_read(cn, buf, sizeof(buf)-1); if (rv <= 0) { @@ -409,12 +309,14 @@ void procreadhead(struct connstruct *cn) /* If we have a blank line, advance to next stage */ if (*next == '\r' || *next == '\n') { - if ((cn->reqtype == TYPE_POST)&&(cn->content_length > 0)) - { - if (init_read_post_data(buf,next,cn,rv) == 0) - return; - } - +#ifndef WIN32 + if (cn->reqtype == TYPE_POST && cn->content_length > 0) + { + if (init_read_post_data(buf,next,cn,rv) == 0) + return; + } +#endif + buildactualfile(cn); cn->state = STATE_WANT_TO_SEND_HEAD; return; @@ -860,6 +762,104 @@ static void decode_path_info(struct connstruct *cn, char *path_info) my_strncpy(cn->filereq, path_info, MAXREQUESTLENGTH); } +static int init_read_post_data(char *buf, char *data, + struct connstruct *cn, int old_rv) +{ + char *next = data; + int rv = old_rv; + char *post_data; + + /* Too much Post data to send. MAXPOSTDATASIZE should be + configured (now it can be chaged in the header file) */ + if (cn->content_length > MAXPOSTDATASIZE) + { + send_error(cn, 418); + return 0; + } + + /* remove CRLF */ + while ((*next == '\r' || *next == '\n') && (next < &buf[rv])) + next++; + + if (cn->post_data == NULL) + { + cn->post_data = (char *) calloc(1, (cn->content_length + 1)); + /* Allocate buffer for the POST data that will be used by proccgi + to send POST data to the CGI script */ + + if (cn->post_data == NULL) + { + printf("axhttpd: could not allocate memory for POST data\n"); + TTY_FLUSH(); + send_error(cn, 599); + return 0; + } + } + + cn->post_state = 0; + cn->post_read = 0; + post_data = cn->post_data; + + while (next < &buf[rv]) + { + /*copy POST data to buffer*/ + *post_data = *next; + post_data++; + next++; + cn->post_read++; + if (cn->post_read == cn->content_length) + { + /* No more POST data to be copied */ + *post_data = '\0'; + return 1; + } + } + + /* More POST data has to be read. read_post_data will continue with that */ + cn->post_state = 1; + return 0; +} + +void read_post_data(struct connstruct *cn) +{ + char buf[MAXREQUESTLENGTH*4], *next; + char *post_data; + int rv; + + bzero(buf,MAXREQUESTLENGTH*4); + rv = special_read(cn, buf, sizeof(buf)-1); + if (rv <= 0) + { + if (rv < 0) /* really dead? */ + removeconnection(cn); + return; + } + + buf[rv] = '\0'; + next = buf; + + post_data = &cn->post_data[cn->post_read]; + + while (next < &buf[rv]) + { + *post_data = *next; + post_data++; + next++; + cn->post_read++; + if (cn->post_read == cn->content_length) + { + /* No more POST data to be copied */ + *post_data='\0'; + cn->post_state = 0; + buildactualfile(cn); + cn->state = STATE_WANT_TO_SEND_HEAD; + return; + } + } + + /* More POST data to read */ +} + #endif /* CONFIG_HTTP_HAS_CGI */ /* Decode string %xx -> char (in place) */ diff --git a/ssl/os_port.c b/ssl/os_port.c index 9b2547389..5f3c47722 100644 --- a/ssl/os_port.c +++ b/ssl/os_port.c @@ -65,8 +65,6 @@ EXP_FUNC int STDCALL strcasecmp(const char *s1, const char *s2) #undef malloc #undef realloc #undef calloc -#undef open -#undef fopen static const char * out_of_mem_str = "out of memory"; static const char * file_open_str = "Could not open file \"%s\""; @@ -106,16 +104,6 @@ EXP_FUNC void * STDCALL ax_calloc(size_t n, size_t s) return x; } -EXP_FUNC FILE * STDCALL ax_fopen(const char *pathname, const char *type) -{ - FILE *f; - - if ((f = fopen(pathname, type)) == NULL) - exit_now(file_open_str, pathname); - - return f; -} - EXP_FUNC int STDCALL ax_open(const char *pathname, int flags) { int x; diff --git a/ssl/os_port.h b/ssl/os_port.h index ea0e7d14c..c6ecb6f83 100644 --- a/ssl/os_port.h +++ b/ssl/os_port.h @@ -86,6 +86,7 @@ extern "C" { #define usleep(A) Sleep(A/1000) #define strdup(A) _strdup(A) #define chroot(A) _chdir(A) +#define chdir(A) _chdir(A) #ifndef lseek #define lseek(A,B,C) _lseek(A,B,C) #endif @@ -157,7 +158,6 @@ EXP_FUNC int STDCALL strcasecmp(const char *s1, const char *s2); EXP_FUNC void * STDCALL ax_malloc(size_t s); EXP_FUNC void * STDCALL ax_realloc(void *y, size_t s); EXP_FUNC void * STDCALL ax_calloc(size_t n, size_t s); -EXP_FUNC FILE * STDCALL ax_fopen(const char *name, const char *type); EXP_FUNC int STDCALL ax_open(const char *pathname, int flags); #ifdef CONFIG_PLATFORM_LINUX