summaryrefslogtreecommitdiffstats
path: root/c/src/libnetworking
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-04-11 14:46:55 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-04-11 14:46:55 +0000
commitee3afa2e2ae017b22156164763a4099702ca472d (patch)
treed41c03f7bf2396e7e01147a9ffd75c7a0a71232c /c/src/libnetworking
parent2003-04-10 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-ee3afa2e2ae017b22156164763a4099702ca472d.tar.bz2
2002-04-10 Mike Siers <mikes@poliac.com>
* rtems_webserver/NOTES, rtems_webserver/asp.c, rtems_webserver/balloc.c, rtems_webserver/default.c, rtems_webserver/ej.h, rtems_webserver/ejIntrn.h, rtems_webserver/ejlex.c, rtems_webserver/ejparse.c, rtems_webserver/emfdb.c, rtems_webserver/emfdb.h, rtems_webserver/form.c, rtems_webserver/h.c, rtems_webserver/handler.c, rtems_webserver/license.txt, rtems_webserver/md5.h, rtems_webserver/md5c.c, rtems_webserver/mime.c, rtems_webserver/misc.c, rtems_webserver/ringq.c, rtems_webserver/rom.c, rtems_webserver/security.c, rtems_webserver/sock.c, rtems_webserver/sym.c, rtems_webserver/uemf.c, rtems_webserver/uemf.h, rtems_webserver/um.c, rtems_webserver/um.h, rtems_webserver/url.c, rtems_webserver/value.c, rtems_webserver/wbase64.c, rtems_webserver/webcomp.c, rtems_webserver/webpage.c, rtems_webserver/webrom.c, rtems_webserver/webs.c, rtems_webserver/webs.h, rtems_webserver/websuemf.c, rtems_webserver/wsIntrn.h: Update to GoAhead Webserver 2.1.4. The following URL is the release notes from GoAhead. http://data.goahead.com/Software/Webserver/2.1.4/release.htm I have only done a minimal amount of testing (i.e. the network demo program works fine). Please try this out and let me know if it works. The patch needs to be applied on the c/src/libnetworking/rtems_webserver directory.
Diffstat (limited to 'c/src/libnetworking')
-rw-r--r--c/src/libnetworking/ChangeLog30
-rw-r--r--c/src/libnetworking/rtems_webserver/NOTES9
-rw-r--r--c/src/libnetworking/rtems_webserver/asp.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/balloc.c72
-rw-r--r--c/src/libnetworking/rtems_webserver/default.c60
-rw-r--r--c/src/libnetworking/rtems_webserver/ej.h4
-rw-r--r--c/src/libnetworking/rtems_webserver/ejIntrn.h10
-rw-r--r--c/src/libnetworking/rtems_webserver/ejlex.c10
-rw-r--r--c/src/libnetworking/rtems_webserver/ejparse.c8
-rw-r--r--c/src/libnetworking/rtems_webserver/emfdb.c8
-rw-r--r--c/src/libnetworking/rtems_webserver/emfdb.h2
-rw-r--r--c/src/libnetworking/rtems_webserver/form.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/h.c14
-rw-r--r--c/src/libnetworking/rtems_webserver/handler.c58
-rw-r--r--c/src/libnetworking/rtems_webserver/license.txt236
-rw-r--r--c/src/libnetworking/rtems_webserver/md5.h3
-rw-r--r--c/src/libnetworking/rtems_webserver/md5c.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/mime.c6
-rw-r--r--c/src/libnetworking/rtems_webserver/misc.c44
-rw-r--r--c/src/libnetworking/rtems_webserver/ringq.c8
-rw-r--r--c/src/libnetworking/rtems_webserver/rom.c4
-rw-r--r--c/src/libnetworking/rtems_webserver/security.c16
-rw-r--r--c/src/libnetworking/rtems_webserver/sock.c30
-rw-r--r--c/src/libnetworking/rtems_webserver/sym.c4
-rw-r--r--c/src/libnetworking/rtems_webserver/uemf.c16
-rw-r--r--c/src/libnetworking/rtems_webserver/uemf.h204
-rw-r--r--c/src/libnetworking/rtems_webserver/um.c20
-rw-r--r--c/src/libnetworking/rtems_webserver/um.h2
-rw-r--r--c/src/libnetworking/rtems_webserver/url.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/value.c38
-rw-r--r--c/src/libnetworking/rtems_webserver/wbase64.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/webcomp.c4
-rw-r--r--c/src/libnetworking/rtems_webserver/webpage.c14
-rw-r--r--c/src/libnetworking/rtems_webserver/webrom.c2
-rw-r--r--c/src/libnetworking/rtems_webserver/webs.c205
-rw-r--r--c/src/libnetworking/rtems_webserver/webs.h12
-rw-r--r--c/src/libnetworking/rtems_webserver/websuemf.c9
-rw-r--r--c/src/libnetworking/rtems_webserver/wsIntrn.h42
38 files changed, 905 insertions, 309 deletions
diff --git a/c/src/libnetworking/ChangeLog b/c/src/libnetworking/ChangeLog
index 1b2de939f2..ea2d0bf722 100644
--- a/c/src/libnetworking/ChangeLog
+++ b/c/src/libnetworking/ChangeLog
@@ -1,3 +1,33 @@
+2002-04-10 Mike Siers <mikes@poliac.com>
+
+ * rtems_webserver/NOTES, rtems_webserver/asp.c,
+ rtems_webserver/balloc.c, rtems_webserver/default.c,
+ rtems_webserver/ej.h, rtems_webserver/ejIntrn.h,
+ rtems_webserver/ejlex.c, rtems_webserver/ejparse.c,
+ rtems_webserver/emfdb.c, rtems_webserver/emfdb.h,
+ rtems_webserver/form.c, rtems_webserver/h.c,
+ rtems_webserver/handler.c, rtems_webserver/license.txt,
+ rtems_webserver/md5.h, rtems_webserver/md5c.c,
+ rtems_webserver/mime.c, rtems_webserver/misc.c,
+ rtems_webserver/ringq.c, rtems_webserver/rom.c,
+ rtems_webserver/security.c, rtems_webserver/sock.c,
+ rtems_webserver/sym.c, rtems_webserver/uemf.c,
+ rtems_webserver/uemf.h, rtems_webserver/um.c, rtems_webserver/um.h,
+ rtems_webserver/url.c, rtems_webserver/value.c,
+ rtems_webserver/wbase64.c, rtems_webserver/webcomp.c,
+ rtems_webserver/webpage.c, rtems_webserver/webrom.c,
+ rtems_webserver/webs.c, rtems_webserver/webs.h,
+ rtems_webserver/websuemf.c, rtems_webserver/wsIntrn.h:
+ Update to GoAhead Webserver 2.1.4. The following URL is
+ the release notes from GoAhead.
+
+ http://data.goahead.com/Software/Webserver/2.1.4/release.htm
+
+ I have only done a minimal amount of testing (i.e. the network
+ demo program works fine). Please try this out and let me know
+ if it works. The patch needs to be applied on the
+ c/src/libnetworking/rtems_webserver directory.
+
2003-04-10 Joel Sherrill <joel@OARcorp.com>
PR 371/pppd
diff --git a/c/src/libnetworking/rtems_webserver/NOTES b/c/src/libnetworking/rtems_webserver/NOTES
index 6b0e4c55b0..e2ef07eb34 100644
--- a/c/src/libnetworking/rtems_webserver/NOTES
+++ b/c/src/libnetworking/rtems_webserver/NOTES
@@ -2,7 +2,7 @@
# $Id$
#
-Notes on merging GoAhead Webs 2.1. Eventually RTEMS should be supported
+Notes on merging GoAhead Webs 2.1.4. Eventually RTEMS should be supported
in their distributions and this directory removed.
Applied patch from Antti P Miettinen <antti.p.miettinen@nokia.com>.
@@ -10,6 +10,13 @@ Applied patch from Antti P Miettinen <antti.p.miettinen@nokia.com>.
Obtain the original distribution from http://www.goahead.com for
documentation.
+Porting
+=======
+ - added rtems complier flags to uemf.h and misc.c
+ - following source files are distributed with the web server
+ but not currently used by RTEMS
+ [cgi.c, sockGen.c, umui.c, websSSL.c, websda.c]
+
Tailoring
=========
socket.c is RTEMS specific
diff --git a/c/src/libnetworking/rtems_webserver/asp.c b/c/src/libnetworking/rtems_webserver/asp.c
index 9b37523e02..7d20e683b7 100644
--- a/c/src/libnetworking/rtems_webserver/asp.c
+++ b/c/src/libnetworking/rtems_webserver/asp.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
diff --git a/c/src/libnetworking/rtems_webserver/balloc.c b/c/src/libnetworking/rtems_webserver/balloc.c
index d535a6605c..aa916444b6 100644
--- a/c/src/libnetworking/rtems_webserver/balloc.c
+++ b/c/src/libnetworking/rtems_webserver/balloc.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -26,7 +28,7 @@
#define IN_BALLOC
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
@@ -35,13 +37,13 @@
#include <stdarg.h>
#include <stdlib.h>
-#if !NO_BALLOC
+#ifndef NO_BALLOC
/********************************* Defines ************************************/
/*
* Define B_STATS if you wish to track memory block and stack usage
*/
-#if B_STATS
+#ifdef B_STATS
/*
* Optional statistics
*/
@@ -107,18 +109,18 @@ static int bopenCount = 0; /* Num tasks using balloc */
/*************************** Forward Declarations *****************************/
-#if B_STATS
+#ifdef B_STATS
static void bStatsAlloc(B_ARGS_DEC, void *ptr, int q, int size);
static void bStatsFree(B_ARGS_DEC, void *ptr, int q, int size);
static void bstatsWrite(int handle, char_t *fmt, ...);
static int bStatsFileSort(const void *cp1, const void *cp2);
#endif /* B_STATS */
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
static void bFillBlock(void *buf, int bufsize);
#endif
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
static void verifyUsedBlock(bType *bp, int q);
static void verifyFreeBlock(bType *bp, int q);
void verifyBallocSpace();
@@ -141,7 +143,7 @@ int bopen(void *buf, int bufsize, int flags)
{
bFlags = flags;
-#if BASTARD_TESTING
+#ifdef BASTARD_TESTING
srand(time(0L));
#endif /* BASTARD_TESTING */
@@ -163,7 +165,7 @@ int bopen(void *buf, int bufsize, int flags)
if ((buf = malloc(bufsize)) == NULL) {
return -1;
}
-#if B_STATS
+#ifdef B_STATS
bStatsMemMalloc += bufsize;
#endif
} else {
@@ -173,13 +175,13 @@ int bopen(void *buf, int bufsize, int flags)
bFreeSize = bFreeLeft = bufsize;
bFreeBuf = bFreeNext = buf;
memset(bQhead, 0, sizeof(bQhead));
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
bFillBlock(buf, bufsize);
#endif
-#if B_STATS
+#ifdef B_STATS
bStackStart = &buf;
#endif
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyFreeBlock(buf, bufsize);
#endif
return 0;
@@ -192,7 +194,7 @@ int bopen(void *buf, int bufsize, int flags)
void bclose()
{
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyBallocSpace();
#endif
if (--bopenCount <= 0 && !(bFlags & B_USER_BUF)) {
@@ -220,14 +222,14 @@ void *balloc(B_ARGS_DEC, int size)
return NULL;
}
}
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyBallocSpace();
#endif
if (size < 0) {
return NULL;
}
-#if BASTARD_TESTING
+#ifdef BASTARD_TESTING
if (rand() == 0x7fff) {
return NULL;
}
@@ -241,7 +243,7 @@ void *balloc(B_ARGS_DEC, int size)
* Size if bigger than the maximum class. Malloc if use has been okayed
*/
if (bFlags & B_USE_MALLOC) {
-#if B_STATS
+#ifdef B_STATS
bstats(0, NULL);
#endif
#ifdef IRIX
@@ -252,10 +254,10 @@ void *balloc(B_ARGS_DEC, int size)
traceRaw(T("B: malloc failed\n"));
return NULL;
}
-#if B_STATS
+#ifdef B_STATS
bStatsMemMalloc += memSize;
#endif
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
bFillBlock(bp, memSize);
#endif
@@ -275,10 +277,10 @@ void *balloc(B_ARGS_DEC, int size)
* Take first block off the relevant q if non-empty
*/
bQhead[q] = bp->u.next;
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyFreeBlock(bp, q);
#endif
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
bFillBlock(bp, memSize);
#endif
bp->u.size = memSize - sizeof(bType);
@@ -291,19 +293,19 @@ void *balloc(B_ARGS_DEC, int size)
* create a new block out of the primary free block
*/
bp = (bType*) bFreeNext;
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyFreeBlock(bp, q);
#endif
bFreeNext += memSize;
bFreeLeft -= memSize;
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
bFillBlock(bp, memSize);
#endif
bp->u.size = memSize - sizeof(bType);
bp->flags = 0;
} else if (bFlags & B_USE_MALLOC) {
-#if B_STATS
+#ifdef B_STATS
static int once = 0;
if (once++ == 0) {
bstats(0, NULL);
@@ -319,10 +321,10 @@ void *balloc(B_ARGS_DEC, int size)
traceRaw(T("B: malloc failed\n"));
return NULL;
}
-#if B_STATS
+#ifdef B_STATS
bStatsMemMalloc += memSize;
#endif
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
bFillBlock(bp, memSize);
#endif
bp->u.size = memSize - sizeof(bType);
@@ -334,7 +336,7 @@ void *balloc(B_ARGS_DEC, int size)
}
}
-#if B_STATS
+#ifdef B_STATS
bStatsAlloc(B_ARGS, bp, q, memSize);
#endif
bp->flags |= B_INTEGRITY;
@@ -344,7 +346,7 @@ void *balloc(B_ARGS_DEC, int size)
* determine and reduce maximum memory use.
*/
#if 0
-#if B_STATS
+#ifdef B_STATS
if (bStatsBallocInUse == bStatsBallocMax) {
bstats(0, NULL);
}
@@ -365,7 +367,7 @@ void bfree(B_ARGS_DEC, void *mp)
bType *bp;
int q, memSize;
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyBallocSpace();
#endif
bp = (bType*) ((char*) mp - sizeof(bType));
@@ -378,10 +380,10 @@ void bfree(B_ARGS_DEC, void *mp)
memSize = ballocGetSize(bp->u.size, &q);
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
verifyUsedBlock(bp,q);
#endif
-#if B_STATS
+#ifdef B_STATS
bStatsFree(B_ARGS, bp, q, bp->u.size+sizeof(bType));
#endif
if (bp->flags & B_MALLOCED) {
@@ -389,7 +391,7 @@ void bfree(B_ARGS_DEC, void *mp)
return;
}
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
bFillBlock(bp, memSize);
#endif
@@ -415,7 +417,7 @@ void bfreeSafe(B_ARGS_DEC, void *mp)
}
/******************************************************************************/
-#if UNICODE
+#ifdef UNICODE
/*
* Duplicate a string, allow NULL pointers and then dup an empty string.
*/
@@ -510,7 +512,7 @@ static int ballocGetSize(int size, int *q)
}
/******************************************************************************/
-#if B_FILL || B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#if (defined (B_FILL) || defined (B_VERIFY_CAUSES_SEVERE_OVERHEAD))
/*
* Fill the block (useful during development to catch zero fill assumptions)
*/
@@ -522,7 +524,7 @@ static void bFillBlock(void *buf, int bufsize)
#endif
/******************************************************************************/
-#if B_STATS
+#ifdef B_STATS
/*
* Statistics. Do output via calling the writefn callback function with
* "handle" as the output file handle.
@@ -816,7 +818,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
#endif /* B_STATS */
/******************************************************************************/
-#if B_VERIFY_CAUSES_SEVERE_OVERHEAD
+#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
/*
* The following routines verify the integrity of the balloc memory space.
* These functions use the B_FILL feature. Corruption is defined
@@ -936,7 +938,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
char_t *bstrdupNoBalloc(char_t *s)
{
-#if UNICODE
+#ifdef UNICODE
if (s) {
return wcsdup(s);
} else {
diff --git a/c/src/libnetworking/rtems_webserver/default.c b/c/src/libnetworking/rtems_webserver/default.c
index 6851995872..9d3510f253 100644
--- a/c/src/libnetworking/rtems_webserver/default.c
+++ b/c/src/libnetworking/rtems_webserver/default.c
@@ -84,17 +84,16 @@ int websDefaultHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
/*
* Open the document. Stat for later use.
*/
- if (websPageOpen(wp, lpath, path, SOCKET_RDONLY | SOCKET_BINARY,
- 0666) < 0) {
- websError(wp, 400,
- T("Cannot open URL <b>%s</b>"), url);
- return 1;
- }
- if (websPageStat(wp, lpath, path, &sbuf) < 0) {
- websError(wp, 400, T("Cannot stat page for URL <b>%s</b>"),
- url);
- return 1;
- }
+ if (websPageOpen(wp, lpath, path, SOCKET_RDONLY | SOCKET_BINARY,
+ 0666) < 0) {
+ websError(wp, 400, T("Cannot open URL <b>%s</b>"), url);
+ return 1;
+ }
+
+ if (websPageStat(wp, lpath, path, &sbuf) < 0) {
+ websError(wp, 400, T("Cannot stat page for URL <b>%s</b>"), url);
+ return 1;
+ }
/*
* If the page has not been modified since the user last received it and it
@@ -102,7 +101,7 @@ int websDefaultHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
* sending a 304 Use local copy response
*/
websStats.localHits++;
-#if WEBS_IF_MODIFIED_SUPPORT
+#ifdef WEBS_IF_MODIFIED_SUPPORT
if (flags & WEBS_IF_MODIFIED && !(flags & WEBS_ASP)) {
if (sbuf.mtime <= wp->since) {
websWrite(wp, T("HTTP/1.0 304 Use local copy\r\n"));
@@ -227,6 +226,38 @@ int websValidateUrl(webs_t wp, char_t *path)
len = npart = 0;
parts[0] = NULL;
+
+ /*
+ * 22 Jul 02 -- there were reports that a directory traversal exploit was
+ * possible in the WebServer running under Windows if directory paths
+ * outside the server's specified root web were given by URL-encoding the
+ * backslash character, like:
+ *
+ * GoAhead is vulnerable to a directory traversal bug. A request such as
+ *
+ * GoAhead-server/../../../../../../../ results in an error message
+ * 'Cannot open URL'.
+
+ * However, by encoding the '/' character, it is possible to break out of
+ * the
+ * web root and read arbitrary files from the server.
+ * Hence a request like:
+ *
+ * GoAhead-server/..%5C..%5C..%5C..%5C..%5C..%5C/winnt/win.ini returns the
+ * contents of the win.ini file.
+ * (Note that the description uses forward slashes (0x2F), but the example
+ * uses backslashes (0x5C). In my tests, forward slashes are correctly
+ * trapped, but backslashes are not. The code below substitutes forward
+ * slashes for backslashes before attempting to validate that there are no
+ * unauthorized paths being accessed.
+ */
+ token = gstrchr(path, '\\');
+ while (token != NULL)
+ {
+ *token = '/';
+ token = gstrchr(token, '\\');
+ }
+
token = gstrtok(path, T("/"));
/*
@@ -284,7 +315,7 @@ static void websDefaultWriteEvent(webs_t wp)
flags = websGetRequestFlags(wp);
- websMarkTime(wp);
+ websSetTimeMark(wp);
wrote = bytes = 0;
written = websGetRequestWritten(wp);
@@ -300,8 +331,7 @@ static void websDefaultWriteEvent(webs_t wp)
*/
if ((buf = balloc(B_L, PAGE_READ_BUFSIZE)) == NULL) {
websError(wp, 200, T("Can't get memory"));
- }
- else {
+ } else {
while ((len = websPageReadData(wp, buf, PAGE_READ_BUFSIZE)) > 0) {
if ((wrote = websWriteDataNonBlock(wp, buf, len)) < 0) {
break;
diff --git a/c/src/libnetworking/rtems_webserver/ej.h b/c/src/libnetworking/rtems_webserver/ej.h
index fa7a51a771..879dae91a7 100644
--- a/c/src/libnetworking/rtems_webserver/ej.h
+++ b/c/src/libnetworking/rtems_webserver/ej.h
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
*
* See the file "license.txt" for information on usage and redistribution
+ *
+ * $Id$
*/
#ifndef _h_EJ
@@ -18,7 +20,7 @@
/********************************* Includes ***********************************/
-#if ! UEMF
+#ifndef UEMF
#include "basic/basic.h"
#include "emf/emf.h"
#else
diff --git a/c/src/libnetworking/rtems_webserver/ejIntrn.h b/c/src/libnetworking/rtems_webserver/ejIntrn.h
index 0ab7b9b5e5..401da17891 100644
--- a/c/src/libnetworking/rtems_webserver/ejIntrn.h
+++ b/c/src/libnetworking/rtems_webserver/ejIntrn.h
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software, Inc., 1992-2000
*
* See the file "license.txt" for information on usage and redistribution
+ *
+ * $Id$
*/
#ifndef _h_EJINTERNAL
@@ -22,13 +24,13 @@
#include <stdarg.h>
#include <stdlib.h>
-#if CE
-#if ! UEMF
+#ifdef CE
+#ifndef UEMF
#include <io.h>
#endif
#endif
-#if LYNX
+#ifdef LYNX
#include <unistd.h>
#endif
@@ -36,7 +38,7 @@
#include <dirent.h>
#endif
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include <param.h>
diff --git a/c/src/libnetworking/rtems_webserver/ejlex.c b/c/src/libnetworking/rtems_webserver/ejlex.c
index ea5cead255..45181d9d83 100644
--- a/c/src/libnetworking/rtems_webserver/ejlex.c
+++ b/c/src/libnetworking/rtems_webserver/ejlex.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -17,7 +19,7 @@
#include "ejIntrn.h"
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
@@ -194,7 +196,13 @@ void ejLexFreeInputState(ej_t* ep, ejinput_t* state)
int ejLexGetToken(ej_t* ep, int state)
{
ep->tid = getLexicalToken(ep, state);
+ /*
+ * commented out 04 Apr 02 Bg Porter -- we found a case where very long
+ * arguments to write() were being corrupted downstream in the trace call
+ * (the ep->token pointer was being overwritten with the trace message.
+ * restore this if it's useful for your debugging.
trace(9, T("ejGetToken: %d, \"%s\"\n"), ep->tid, ep->token);
+ */
return ep->tid;
}
diff --git a/c/src/libnetworking/rtems_webserver/ejparse.c b/c/src/libnetworking/rtems_webserver/ejparse.c
index 8863c069ea..383984e88f 100644
--- a/c/src/libnetworking/rtems_webserver/ejparse.c
+++ b/c/src/libnetworking/rtems_webserver/ejparse.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -17,7 +19,7 @@
#include "ejIntrn.h"
-#if CE
+#ifdef CE
#include "CE/wincompat.h"
#endif
@@ -98,7 +100,7 @@ int ejOpenEngine(sym_fd_t variables, sym_fd_t functions)
*/
ejSetGlobalVar(ep->eid, T("null"), NULL);
-#if EMF
+#ifdef EMF
ejEmfOpen(ep->eid);
#endif
return ep->eid;
@@ -118,7 +120,7 @@ void ejCloseEngine(int eid)
return;
}
-#if EMF
+#ifdef EMF
ejEmfClose(eid);
#endif
diff --git a/c/src/libnetworking/rtems_webserver/emfdb.c b/c/src/libnetworking/rtems_webserver/emfdb.c
index 9a0c1dd1e3..ae3e9a362e 100644
--- a/c/src/libnetworking/rtems_webserver/emfdb.c
+++ b/c/src/libnetworking/rtems_webserver/emfdb.c
@@ -662,7 +662,7 @@ static int dbWriteKeyValue(int fd, char_t *key, char_t *value)
if (pLineOut) {
len = gstrlen(pLineOut);
-#if CE
+#ifdef CE
rc = writeUniToAsc(fd, pLineOut, len);
#else
rc = gwrite(fd, pLineOut, len);
@@ -853,7 +853,7 @@ int dbLoad(int did, char_t *filename, int flags)
* Read entire file into temporary buffer
*/
buf = balloc(B_L, sbuf.st_size + 1);
-#if CE
+#ifdef CE
if (readAscToUni(fd, &buf, sbuf.st_size) != (int)sbuf.st_size) {
#else
if (gread(fd, buf, sbuf.st_size) != (int)sbuf.st_size) {
@@ -1019,8 +1019,8 @@ void basicSetProductDir(char_t *proddir)
{
int len;
- if (basicProdDir != NULL) {
- bfree(B_L, basicProdDir);
+ if (basicProdDir != NULL) {
+ bfree(B_L, basicProdDir);
}
basicProdDir = bstrdup(B_L, proddir);
diff --git a/c/src/libnetworking/rtems_webserver/emfdb.h b/c/src/libnetworking/rtems_webserver/emfdb.h
index 0ba7e67401..00319f64ee 100644
--- a/c/src/libnetworking/rtems_webserver/emfdb.h
+++ b/c/src/libnetworking/rtems_webserver/emfdb.h
@@ -18,7 +18,7 @@
#ifndef _h_EMFDB
#define _h_EMFDB 1
-#if ! UEMF
+#ifndef UEMF
#include "basic/basic.h"
#include "emf/emf.h"
#else
diff --git a/c/src/libnetworking/rtems_webserver/form.c b/c/src/libnetworking/rtems_webserver/form.c
index dbad2d2e78..501cea72e2 100644
--- a/c/src/libnetworking/rtems_webserver/form.c
+++ b/c/src/libnetworking/rtems_webserver/form.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/********************************** Description *******************************/
diff --git a/c/src/libnetworking/rtems_webserver/h.c b/c/src/libnetworking/rtems_webserver/h.c
index 23bc1ddd9c..abafbb17a2 100644
--- a/c/src/libnetworking/rtems_webserver/h.c
+++ b/c/src/libnetworking/rtems_webserver/h.c
@@ -3,6 +3,8 @@
*
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -15,7 +17,7 @@
/********************************* Includes ***********************************/
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
@@ -41,7 +43,7 @@
* element in the handle array.
*/
-#if B_STATS
+#ifdef B_STATS
int HALLOC(B_ARGS_DEC, void ***map)
#else
int hAlloc(void ***map)
@@ -55,7 +57,7 @@ int hAlloc(void ***map)
if (*map == NULL) {
incr = H_INCR;
memsize = (incr + H_OFFSET) * sizeof(void**);
-#if B_STATS
+#ifdef B_STATS
if ((mp = (int*) balloc(B_ARGS, memsize)) == NULL) {
#else
if ((mp = (int*) balloc(B_L, memsize)) == NULL) {
@@ -148,7 +150,7 @@ int hFree(void ***map, int handle)
* Allocate an entry in the halloc array.
*/
-#if B_STATS
+#ifdef B_STATS
int HALLOCENTRY(B_ARGS_DEC, void ***list, int *max, int size)
#else
int hAllocEntry(void ***list, int *max, int size)
@@ -160,7 +162,7 @@ int hAllocEntry(void ***list, int *max, int size)
a_assert(list);
a_assert(max);
-#if B_STATS
+#ifdef B_STATS
if ((id = HALLOC(B_ARGS, (void***) list)) < 0) {
#else
if ((id = hAlloc((void***) list)) < 0) {
@@ -169,7 +171,7 @@ int hAllocEntry(void ***list, int *max, int size)
}
if (size > 0) {
-#if B_STATS
+#ifdef B_STATS
if ((cp = balloc(B_ARGS, size)) == NULL) {
#else
if ((cp = balloc(B_L, size)) == NULL) {
diff --git a/c/src/libnetworking/rtems_webserver/handler.c b/c/src/libnetworking/rtems_webserver/handler.c
index 88693bf9a6..dbbe4148d5 100644
--- a/c/src/libnetworking/rtems_webserver/handler.c
+++ b/c/src/libnetworking/rtems_webserver/handler.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -25,10 +27,10 @@ static int urlHandlerOpenCount = 0; /* count of apps */
/**************************** Forward Declarations ****************************/
-static int websUrlHandlerSort(const void *p1, const void *p2);
-static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
+static int websUrlHandlerSort(const void *p1, const void *p2);
+static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
int sid, char_t *url, char_t *path, char_t *query);
-static int websTidyUrl(webs_t wp);
+static char_t *websCondenseMultipleChars(char_t *strToCondense, char_t cCondense);
/*********************************** Code *************************************/
/*
@@ -256,7 +258,11 @@ int websUrlHandlerRequest(webs_t wp)
websSetRequestPath(wp, websGetDefaultDir(), NULL);
- websTidyUrl(wp);
+/*
+ * Eliminate security hole
+ */
+ websCondenseMultipleChars(wp->path, '/');
+ websCondenseMultipleChars(wp->url, '/');
/*
* We loop over each handler in order till one accepts the request.
@@ -292,6 +298,7 @@ int websUrlHandlerRequest(webs_t wp)
return 0;
}
+#ifdef OBSOLETE_CODE
/******************************************************************************/
/*
@@ -358,4 +365,47 @@ static int websTidyUrl(webs_t wp)
}
}
+#endif
+
+/******************************************************************************/
+/*
+ * Convert multiple adjacent occurrences of a given character to a single
+ * instance.
+ */
+
+static char_t *websCondenseMultipleChars(char_t *strToCondense, char_t cCondense)
+{
+ if (strToCondense != NULL) {
+ char_t *pStr, *pScan;
+
+ pStr = pScan = strToCondense;
+
+ while (*pScan && *pStr) {
+/*
+ * Advance scan pointer over multiple occurences of condense character
+ */
+ while ((*pScan == cCondense) && (*(pScan + 1) == cCondense)) {
+ pScan++;
+ }
+/*
+ * Copy character if an advance of the scan pointer has occurred
+ */
+ if (pStr != pScan) {
+ *pStr = *pScan;
+ }
+
+ pScan++;
+ pStr++;
+ }
+/*
+ * Zero terminate string if multiple adjacent characters were found and condensed
+ */
+ if (pStr != pScan) {
+ *pStr = 0;
+ }
+ }
+
+ return strToCondense;
+}
+
/******************************************************************************/
diff --git a/c/src/libnetworking/rtems_webserver/license.txt b/c/src/libnetworking/rtems_webserver/license.txt
index b10d3ddb1d..1fa9e67e79 100644
--- a/c/src/libnetworking/rtems_webserver/license.txt
+++ b/c/src/libnetworking/rtems_webserver/license.txt
@@ -1,114 +1,272 @@
License Agreement
-THIS LICENSE ALLOWS ONLY THE LIMITED USE OF GO AHEAD SOFTWARE, INC. PROPRIETARY CODE. PLEASE CAREFULLY READ THIS AGREEMENT AS IT PERTAINS TO THIS LICENSE, YOU CERTIFY THAT YOU WILL USE THE SOFTWARE ONLY IN THE MANNER PERMITTED HEREIN.
+THIS LICENSE ALLOWS ONLY THE LIMITED USE OF GO AHEAD SOFTWARE,
+INC. PROPRIETARY CODE. PLEASE CAREFULLY READ THIS AGREEMENT AS IT
+PERTAINS TO THIS LICENSE, YOU CERTIFY THAT YOU WILL USE THE SOFTWARE
+ONLY IN THE MANNER PERMITTED HEREIN.
1. Definitions.
-1.1 "Documentation" means any documentation GoAhead includes with the Original Code.
+1.1 "Documentation" means any documentation GoAhead includes with the
+Original Code.
1.2 "GoAhead" means Go Ahead Software, Inc.
-1.3 "Intellectual Property Rights" means all rights, whether now existing or hereinafter acquired, in and to trade secrets, patents, copyrights, trademarks, know-how, as well as moral rights and similar rights of any type under the laws of any governmental authority, domestic or foreign, including rights in and to all applications and registrations relating to any of the foregoing.
+1.3 "Intellectual Property Rights" means all rights, whether now existing
+or hereinafter acquired, in and to trade secrets, patents, copyrights,
+trademarks, know-how, as well as moral rights and similar rights of any
+type under the laws of any governmental authority, domestic or foreign,
+including rights in and to all applications and registrations relating
+to any of the foregoing.
1.4 "License" or "Agreement" means this document.
-1.5 "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications.
+1.5 "Modifications" means any addition to or deletion from the substance
+or structure of either the Original Code or any previous Modifications.
-1.6 "Original Code" means the Source Code to GoAhead’s proprietary computer software entitled GoAhead WebServer.
+1.6 "Original Code" means the Source Code to GoAhead’s proprietary
+computer software entitled GoAhead WebServer.
-1.7 "Response Header" means the first portion of the response message output by the GoAhead WebServer, containing but not limited to, header fields for date, content-type, server identification and cache control.
+1.7 "Response Header" means the first portion of the response message
+output by the GoAhead WebServer, containing but not limited to, header
+fields for date, content-type, server identification and cache control.
-1.8 "Server Identification Field" means the field in the Response Header which contains the text "Server: GoAhead-Webs".
+1.8 "Server Identification Field" means the field in the Response Header
+which contains the text "Server: GoAhead-Webs".
-1.9 "You" means an individual or a legal entity exercising rights under, and complying with all of the terms of, this license or a future version of this license. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity.
+1.9 "You" means an individual or a legal entity exercising rights under,
+and complying with all of the terms of, this license or a future version
+of this license. For legal entities, "You" includes any entity which
+controls, is controlled by, or is under common control with You. For
+purposes of this definition, "control" means (a) the power, direct or
+indirect, to cause the direction or management of such entity, whether
+by contract or otherwise, or (b) ownership of fifty percent (50%) or
+more of the outstanding shares or beneficial ownership of such entity.
2. Source Code License.
2.1 Limited Source Code Grant.
-GoAhead hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims, to use, reproduce, modify, copy and distribute the Original Code.
+GoAhead hereby grants You a world-wide, royalty-free, non-exclusive
+license, subject to third party intellectual property claims, to use,
+reproduce, modify, copy and distribute the Original Code.
2.2 Binary Code.
-GoAhead hereby grants You a world-wide, royalty-free, non-exclusive license to copy and distribute the binary code versions of the Original Code together with Your Modifications.
+GoAhead hereby grants You a world-wide, royalty-free, non-exclusive
+license to copy and distribute the binary code versions of the Original
+Code together with Your Modifications.
2.3 License Back to GoAhead.
-You hereby grant in both source code and binary code to GoAhead a world-wide, royalty-free, non-exclusive license to copy, modify, display, use and sublicense any Modifications You make that are distributed or planned for distribution. Within 30 days of either such event, You agree to ship to GoAhead a file containing the Modifications (in a media to be determined by the parties), including any programmers’ notes and other programmers’ materials. Additionally, You will provide to GoAhead a complete description of the product, the product code or model number, the date on which the product is initially shipped, and a contact name, phone number and e-mail address for future correspondence. GoAhead will keep confidential all data specifically marked as such.
+You hereby grant in both source code and binary code to GoAhead a
+world-wide, royalty-free, non-exclusive license to copy, modify, display,
+use and sublicense any Modifications You make that are distributed or
+planned for distribution. Within 30 days of either such event, You
+agree to ship to GoAhead a file containing the Modifications (in a media
+to be determined by the parties), including any programmers’ notes and
+other programmers’ materials. Additionally, You will provide to GoAhead
+a complete description of the product, the product code or model number,
+the date on which the product is initially shipped, and a contact name,
+phone number and e-mail address for future correspondence. GoAhead will
+keep confidential all data specifically marked as such.
2.4 Restrictions on Use.
-You may sublicense Modifications to third parties such as subcontractors or OEM's provided that You enter into license agreements with such third parties that bind such third parties to all the obligations under this Agreement applicable to you and that are otherwise substantially similar in scope and application to this Agreement.
+You may sublicense Modifications to third parties such as subcontractors
+or OEM's provided that You enter into license agreements with such third
+parties that bind such third parties to all the obligations under this
+Agreement applicable to you and that are otherwise substantially similar
+in scope and application to this Agreement.
3. Term.
-This Agreement and license are effective from the time You accept the terms of this Agreement until this Agreement is terminated. You may terminate this Agreement at any time by uninstalling or destroying all copies of the Original Code including any and all binary versions and removing any Modifications to the Original Code existing in any products. This Agreement will terminate immediately and without further notice if You fail to comply with any provision of this Agreement. All restrictions on use, and all other provisions that may reasonably be interpreted to survive termination of this Agreement, will survive termination of this Agreement for any reason. Upon termination, You agree to uninstall or destroy all copies of the Original Code, Modifications, and Documentation.
+This Agreement and license are effective from the time You accept the
+terms of this Agreement until this Agreement is terminated. You may
+terminate this Agreement at any time by uninstalling or destroying
+all copies of the Original Code including any and all binary versions
+and removing any Modifications to the Original Code existing in any
+products. This Agreement will terminate immediately and without further
+notice if You fail to comply with any provision of this Agreement. All
+restrictions on use, and all other provisions that may reasonably
+be interpreted to survive termination of this Agreement, will survive
+termination of this Agreement for any reason. Upon termination, You agree
+to uninstall or destroy all copies of the Original Code, Modifications,
+and Documentation.
4. Trademarks and Brand.
4.1 License and Use.
-GoAhead hereby grants to You a limited world-wide, royalty-free, non-exclusive license to use the GoAhead trade names, trademarks, logos, service marks and product designations posted in Exhibit A (collectively, the "GoAhead Marks") in connection with the activities by You under this Agreement. Additionally, GoAhead grants You a license under the terms above to such GoAhead trademarks as shall be identified at a URL (the "URL") provided by GoAhead. The use by You of GoAhead Marks shall be in accordance with GoAhead’s trademark policies regarding trademark usage as established at the web site designated by the URL, or as otherwise communicated to You by GoAhead at its sole discretion. You understand and agree that any use of GoAhead Marks in connection with this Agreement shall not create any right, title or interest in or to such GoAhead Marks and that all such use and goodwill associated with GoAhead Marks will inure to the benefit of GoAhead.
+GoAhead hereby grants to You a limited world-wide, royalty-free,
+non-exclusive license to use the GoAhead trade names, trademarks, logos,
+service marks and product designations posted in Exhibit A (collectively,
+the "GoAhead Marks") in connection with the activities by You under this
+Agreement. Additionally, GoAhead grants You a license under the terms
+above to such GoAhead trademarks as shall be identified at a URL (the
+"URL") provided by GoAhead. The use by You of GoAhead Marks shall be in
+accordance with GoAhead’s trademark policies regarding trademark usage
+as established at the web site designated by the URL, or as otherwise
+communicated to You by GoAhead at its sole discretion. You understand and
+agree that any use of GoAhead Marks in connection with this Agreement
+shall not create any right, title or interest in or to such GoAhead
+Marks and that all such use and goodwill associated with GoAhead Marks
+will inure to the benefit of GoAhead.
4.2 Promotion by You of GoAhead WebServer Mark.
-In consideration for the licenses granted by GoAhead to You herein, You agree to notify GoAhead when You incorporate the GoAhead WebServer in Your product and to inform GoAhead when such product begins to ship. You agree to promote the Original Code by prominently and visibly displaying a graphic of the GoAhead WebServer mark on the initial web page of Your product that is displayed each time a user connects to it. You also agree that GoAhead may identify your company as a user of the GoAhead WebServer in conjunction with its own marketing efforts. You may further promote the Original Code by displaying the GoAhead WebServer mark in marketing and promotional materials such as the home page of your web site or web pages promoting the product.
+In consideration for the licenses granted by GoAhead to You herein, You
+agree to notify GoAhead when You incorporate the GoAhead WebServer in
+Your product and to inform GoAhead when such product begins to ship. You
+agree to promote the Original Code by prominently and visibly displaying
+a graphic of the GoAhead WebServer mark on the initial web page of Your
+product that is displayed each time a user connects to it. You also agree
+that GoAhead may identify your company as a user of the GoAhead WebServer
+in conjunction with its own marketing efforts. You may further promote
+the Original Code by displaying the GoAhead WebServer mark in marketing
+and promotional materials such as the home page of your web site or web
+pages promoting the product.
4.3 Placement of Copyright Notice by You.
-You agree to include copies of the following notice (the "Notice") regarding proprietary rights in all copies of the products that You distribute, as follows: (i) embedded in the object code; and (ii) on the title pages of all documentation. Furthermore, You agree to use commercially reasonable efforts to cause any licensees of your products to embed the Notice in object code and on the title pages or relevant documentation. The Notice is as follows: Copyright (c) 20xx GoAhead Software, Inc. All Rights Reserved. Unless GoAhead otherwise instructs, the year 20xx is to be replaced with the year during which the release of the Original Code containing the notice is issued by GoAhead. If this year is not supplied with Documentation, GoAhead will supply it upon request.
+You agree to include copies of the following notice (the "Notice")
+regarding proprietary rights in all copies of the products that You
+distribute, as follows: (i) embedded in the object code; and (ii) on
+the title pages of all documentation. Furthermore, You agree to use
+commercially reasonable efforts to cause any licensees of your products
+to embed the Notice in object code and on the title pages or relevant
+documentation. The Notice is as follows: Copyright (c) 20xx GoAhead
+Software, Inc. All Rights Reserved. Unless GoAhead otherwise instructs,
+the year 20xx is to be replaced with the year during which the release of
+the Original Code containing the notice is issued by GoAhead. If this year
+is not supplied with Documentation, GoAhead will supply it upon request.
4.4 No Modifications to Server Identification Field.
-You agree not to remove or modify the Server identification Field contained in the Response Header as defined in Section 1.6 and 1.7.
+You agree not to remove or modify the Server identification Field
+contained in the Response Header as defined in Section 1.6 and 1.7.
5. Warranty Disclaimers.
-THE ORIGINAL CODE, THE DOCUMENTATION AND THE MEDIA UPON WHICH THE ORIGINAL CODE IS RECORDED (IF ANY) ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS, STATUTORY OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-The entire risk as to the quality and performance of the Original Code (including any Modifications You make) and the Documentation is with You. Should the Original Code or the Documentation prove defective, You (and not GoAhead or its distributors, licensors or dealers) assume the entire cost of all necessary servicing or repair. GoAhead does not warrant that the functions contained in the Original Code will meet your requirements or operate in the combination that You may select for use, that the operation of the Original Code will be uninterrupted or error free, or that defects in the Original Code will be corrected. No oral or written statement by GoAhead or by a representative of GoAhead shall create a warranty or increase the scope of this warranty.
-
-GOAHEAD DOES NOT WARRANT THE ORIGINAL CODE AGAINST INFRINGEMENT OR THE LIKE WITH RESPECT TO ANY COPYRIGHT, PATENT, TRADE SECRET, TRADEMARK OR OTHER PROPRIETARY RIGHT OF ANY THIRD PARTY AND DOES NOT WARRANT THAT THE ORIGINAL CODE DOES NOT INCLUDE ANY VIRUS, SOFTWARE ROUTINE OR OTHER SOFTWARE DESIGNED TO PERMIT UNAUTHORIZED ACCESS, TO DISABLE, ERASE OR OTHERWISE HARM SOFTWARE, HARDWARE OR DATA, OR TO PERFORM ANY OTHER SUCH ACTIONS.
-
-Any warranties that by law survive the foregoing disclaimers shall terminate ninety (90) days from the date You received the Original Code.
+THE ORIGINAL CODE, THE DOCUMENTATION AND THE MEDIA UPON WHICH THE ORIGINAL
+CODE IS RECORDED (IF ANY) ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES OF
+ANY KIND, EXPRESS, STATUTORY OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.
+
+The entire risk as to the quality and performance of the Original Code
+(including any Modifications You make) and the Documentation is with
+You. Should the Original Code or the Documentation prove defective,
+You (and not GoAhead or its distributors, licensors or dealers) assume
+the entire cost of all necessary servicing or repair. GoAhead does not
+warrant that the functions contained in the Original Code will meet your
+requirements or operate in the combination that You may select for use,
+that the operation of the Original Code will be uninterrupted or error
+free, or that defects in the Original Code will be corrected. No oral
+or written statement by GoAhead or by a representative of GoAhead shall
+create a warranty or increase the scope of this warranty.
+
+GOAHEAD DOES NOT WARRANT THE ORIGINAL CODE AGAINST INFRINGEMENT OR THE
+LIKE WITH RESPECT TO ANY COPYRIGHT, PATENT, TRADE SECRET, TRADEMARK
+OR OTHER PROPRIETARY RIGHT OF ANY THIRD PARTY AND DOES NOT WARRANT
+THAT THE ORIGINAL CODE DOES NOT INCLUDE ANY VIRUS, SOFTWARE ROUTINE
+OR OTHER SOFTWARE DESIGNED TO PERMIT UNAUTHORIZED ACCESS, TO DISABLE,
+ERASE OR OTHERWISE HARM SOFTWARE, HARDWARE OR DATA, OR TO PERFORM ANY
+OTHER SUCH ACTIONS.
+
+Any warranties that by law survive the foregoing disclaimers shall
+terminate ninety (90) days from the date You received the Original Code.
6. Limitation of Liability.
-YOUR SOLE REMEDIES AND GOAHEAD'S ENTIRE LIABILITY ARE SET FORTH ABOVE. IN NO EVENT WILL GOAHEAD OR ITS DISTRIBUTORS OR DEALERS BE LIABLE FOR DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THE ORIGINAL CODE, THE INABILITY TO USE THE ORIGINAL CODE, OR ANY DEFECT IN THE ORIGINAL CODE, INCLUDING ANY LOST PROFITS, EVEN IF THEY HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+YOUR SOLE REMEDIES AND GOAHEAD'S ENTIRE LIABILITY ARE SET FORTH ABOVE. IN
+NO EVENT WILL GOAHEAD OR ITS DISTRIBUTORS OR DEALERS BE LIABLE FOR
+DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES RESULTING FROM
+THE USE OF THE ORIGINAL CODE, THE INABILITY TO USE THE ORIGINAL CODE,
+OR ANY DEFECT IN THE ORIGINAL CODE, INCLUDING ANY LOST PROFITS, EVEN IF
+THEY HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-You agree that GoAhead and its distributors and dealers will not be LIABLE for defense or indemnity with respect to any claim against You by any third party arising from your possession or use of the Original Code or the Documentation.
+You agree that GoAhead and its distributors and dealers will not be
+LIABLE for defense or indemnity with respect to any claim against You
+by any third party arising from your possession or use of the Original
+Code or the Documentation.
-In no event will GoAhead’s total liability to You for all damages, losses, and causes of action (whether in contract, tort, including negligence, or otherwise) exceed the amount You paid for this product.
+In no event will GoAhead’s total liability to You for all damages, losses,
+and causes of action (whether in contract, tort, including negligence,
+or otherwise) exceed the amount You paid for this product.
-SOME STATES DO NOT ALLOW LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY LASTS, AND SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATIONS OR EXCLUSIONS MAY NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM STATE TO STATE.
+SOME STATES DO NOT ALLOW LIMITATIONS ON HOW LONG AN IMPLIED WARRANTY
+LASTS, AND SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION
+OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATIONS OR
+EXCLUSIONS MAY NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGAL
+RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM STATE TO STATE.
7. Indemnification by You.
-You agree to indemnify and hold GoAhead harmless against any and all claims, losses, damages and costs (including legal expenses and reasonable counsel fees) arising out of any claim of a third party with respect to the contents of the Your products, and any intellectual property rights or other rights or interests related thereto.
+You agree to indemnify and hold GoAhead harmless against any and all
+claims, losses, damages and costs (including legal expenses and reasonable
+counsel fees) arising out of any claim of a third party with respect to
+the contents of the Your products, and any intellectual property rights
+or other rights or interests related thereto.
8. High Risk Activities.
-The Original Code is not fault-tolerant and is not designed , manufactured or intended for use or resale as online control equipment in hazardous environments requiring fail-safe performance, such as in the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, direct life support machines or weapons systems, in which the failure of the Original Code could lead directly to death, personal injury, or severe physical or environmental damage. GoAhead and its suppliers specifically disclaim any express or implied warranty of fitness for any high risk uses listed above.
+The Original Code is not fault-tolerant and is not designed , manufactured
+or intended for use or resale as online control equipment in hazardous
+environments requiring fail-safe performance, such as in the operation
+of nuclear facilities, aircraft navigation or communication systems,
+air traffic control, direct life support machines or weapons systems,
+in which the failure of the Original Code could lead directly to death,
+personal injury, or severe physical or environmental damage. GoAhead and
+its suppliers specifically disclaim any express or implied warranty of
+fitness for any high risk uses listed above.
9. Government Restricted Rights.
-For units of the Department of Defense, use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013. Contractor/manufacturer is GoAhead Software, Inc., 10900 N.E. 8th Street, Suite 750, Bellevue, Washington 98004.
-
-If the Commercial Computer Software Restricted rights clause at FAR 52.227-19 or its successors apply, the Software and Documentation constitute restricted computer software as defined in that clause and the Government shall not have the license for published software set forth in subparagraph (c)(3) of that clause.
-
-The Original Code (i) was developed at private expense, and no part of it was developed with governmental funds; (ii) is a trade secret of GoAhead (or its licensor(s)) for all purposes of the Freedom of Information Act; (iii) is "restricted computer software" subject to limited utilization as provided in the contract between the vendor and the governmental entity; and (iv) in all respects is proprietary data belonging solely to GoAhead (or its licensor(s)).
+For units of the Department of Defense, use, duplication, or disclosure
+by the Government is subject to restrictions as set forth in subparagraph
+(c)(1)(ii) of the Rights in Technical Data and Computer Software clause
+at DFARS 252.227-7013. Contractor/manufacturer is GoAhead Software,
+Inc., 10900 N.E. 8th Street, Suite 750, Bellevue, Washington 98004.
+
+If the Commercial Computer Software Restricted rights clause at FAR
+52.227-19 or its successors apply, the Software and Documentation
+constitute restricted computer software as defined in that clause and
+the Government shall not have the license for published software set
+forth in subparagraph (c)(3) of that clause.
+
+The Original Code (i) was developed at private expense, and no part of it
+was developed with governmental funds; (ii) is a trade secret of GoAhead
+(or its licensor(s)) for all purposes of the Freedom of Information Act;
+(iii) is "restricted computer software" subject to limited utilization as
+provided in the contract between the vendor and the governmental entity;
+and (iv) in all respects is proprietary data belonging solely to GoAhead
+(or its licensor(s)).
10. Governing Law and Interpretation.
-This Agreement shall be interpreted under and governed by the laws of the State of Washington, without regard to its rules governing the conflict of laws. If any provision of this Agreement is held illegal or unenforceable by a court or tribunal of competent jurisdiction, the remaining provisions of this Agreement shall remain in effect and the invalid provision deemed modified to the least degree necessary to remedy such invalidity.
+This Agreement shall be interpreted under and governed by the laws of the
+State of Washington, without regard to its rules governing the conflict of
+laws. If any provision of this Agreement is held illegal or unenforceable
+by a court or tribunal of competent jurisdiction, the remaining provisions
+of this Agreement shall remain in effect and the invalid provision deemed
+modified to the least degree necessary to remedy such invalidity.
11. Entire Agreement.
-This Agreement is the complete agreement between GoAhead and You and supersedes all prior agreements, oral or written, with respect to the subject matter hereof.
+This Agreement is the complete agreement between GoAhead and You and
+supersedes all prior agreements, oral or written, with respect to the
+subject matter hereof.
-If You have any questions concerning this Agreement, You may write to GoAhead Software, Inc., 10900 N.E. 8th Street, Suite 750, Bellevue, Washington 98004 or send e-mail to info@goahead.com.
+If You have any questions concerning this Agreement, You may write to
+GoAhead Software, Inc., 10900 N.E. 8th Street, Suite 750, Bellevue,
+Washington 98004 or send e-mail to info@goahead.com.
-BY CLICKING ON THE "Register" BUTTON ON THE REGISTRATION FORM, YOU ACCEPT AND AGREE TO BE BOUND BY ALL OF THE TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF YOU DO NOT WISH TO ACCEPT THIS LICENSE OR YOU DO NOT QUALIFY FOR A LICENSE BASED ON THE TERMS SET FORTH ABOVE, YOU MUST NOT CLICK THE "Register" BUTTON.
+BY CLICKING ON THE "Register" BUTTON ON THE REGISTRATION FORM, YOU
+ACCEPT AND AGREE TO BE BOUND BY ALL OF THE TERMS AND CONDITIONS SET
+FORTH IN THIS AGREEMENT. IF YOU DO NOT WISH TO ACCEPT THIS LICENSE OR
+YOU DO NOT QUALIFY FOR A LICENSE BASED ON THE TERMS SET FORTH ABOVE,
+YOU MUST NOT CLICK THE "Register" BUTTON.
Exhibit A
diff --git a/c/src/libnetworking/rtems_webserver/md5.h b/c/src/libnetworking/rtems_webserver/md5.h
index 5a782fba2e..8531a07fd4 100644
--- a/c/src/libnetworking/rtems_webserver/md5.h
+++ b/c/src/libnetworking/rtems_webserver/md5.h
@@ -1,4 +1,6 @@
/* MD5.H - header file for MD5C.C
+ *
+ * $Id$
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
@@ -46,3 +48,4 @@ extern void MD5Update (MD5_CONTEXT *, unsigned char *, unsigned int);
extern void MD5Final (unsigned char [16], MD5_CONTEXT *);
#endif /* _h_MD5 */
+
diff --git a/c/src/libnetworking/rtems_webserver/md5c.c b/c/src/libnetworking/rtems_webserver/md5c.c
index 90142cf785..1e5a3442fa 100644
--- a/c/src/libnetworking/rtems_webserver/md5c.c
+++ b/c/src/libnetworking/rtems_webserver/md5c.c
@@ -1,4 +1,6 @@
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ *
+ * $Id$
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
diff --git a/c/src/libnetworking/rtems_webserver/mime.c b/c/src/libnetworking/rtems_webserver/mime.c
index daa467f9cc..689360ea68 100644
--- a/c/src/libnetworking/rtems_webserver/mime.c
+++ b/c/src/libnetworking/rtems_webserver/mime.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -22,6 +24,7 @@
* Addd entries to the MimeList as required for your content
*/
+
websMimeType websMimeList[] = {
{ T("application/java"), T(".class") },
{ T("application/java"), T(".jar") },
@@ -32,8 +35,9 @@ websMimeType websMimeList[] = {
{ T("image/jpeg"), T(".jpg") },
{ T("text/css"), T(".css") },
{ T("text/plain"), T(".txt") },
+ { T("application/x-javascript"), T(".js") },
-#if MORE_MIME_TYPES
+#ifdef MORE_MIME_TYPES
{ T("application/binary"), T(".exe") },
{ T("application/compress"), T(".z") },
{ T("application/gzip"), T(".gz") },
diff --git a/c/src/libnetworking/rtems_webserver/misc.c b/c/src/libnetworking/rtems_webserver/misc.c
index 58cee6ab84..872693593b 100644
--- a/c/src/libnetworking/rtems_webserver/misc.c
+++ b/c/src/libnetworking/rtems_webserver/misc.c
@@ -4,11 +4,13 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/********************************* Includes ***********************************/
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
@@ -49,6 +51,9 @@ enum flag {
static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg,
int msize);
+#if !defined(__rtems__)
+static int strnlen(char_t *s, unsigned int n);
+#endif
static void put_char(strbuf_t *buf, char_t c);
static void put_string(strbuf_t *buf, char_t *s, int len,
int width, int prec, enum flag f);
@@ -58,15 +63,15 @@ static void put_ulong(strbuf_t *buf, unsigned long int value, int base,
/************************************ Code ************************************/
/*
* "basename" returns a pointer to the last component of a pathname
- * LINUX and LynxOS have their own basename function
+ * LINUX, LynxOS and Mac OS X have their own basename function
*/
-#if ! LINUX && ! LYNX && ! __rtems__
+#if (!defined (LINUX) && !defined (LYNX) && !defined (MACOSX))
char_t *basename(char_t *name)
{
char_t *cp;
-#if NW || WIN
+#if (defined (NW) || defined (WIN))
if (((cp = gstrrchr(name, '\\')) == NULL) &&
((cp = gstrrchr(name, '/')) == NULL)) {
return name;
@@ -82,7 +87,7 @@ char_t *basename(char_t *name)
return ++cp;
}
}
-#endif /* ! LINUX & ! LYNX */
+#endif /* ! LINUX & ! LYNX & ! MACOSX */
/******************************************************************************/
/*
@@ -99,7 +104,7 @@ char_t *dirname(char_t *buf, char_t *name, int bufsize)
a_assert(buf);
a_assert(bufsize > 0);
-#if WIN || NW
+#if (defined (WIN) || defined (NW))
if ((cp = gstrrchr(name, '/')) == NULL &&
(cp = gstrrchr(name, '\\')) == NULL)
#else
@@ -343,7 +348,11 @@ static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg, int msize)
prec, f);
}
} else {
+ /* 04 Apr 02 BgP -- changed so that %X correctly outputs
+ * uppercase hex digits when requested.
put_ulong(&buf, value, 16, 0, NULL, width, prec, f);
+ */
+ put_ulong(&buf, value, 16, ('X' == c) , NULL, width, prec, f);
}
}
@@ -408,6 +417,21 @@ static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg, int msize)
/******************************************************************************/
/*
+ * Return the length of a string limited by a given length
+ */
+
+#if !defined(__rtems__)
+static int strnlen(char_t *s, unsigned int n)
+{
+ unsigned int len;
+
+ len = gstrlen(s);
+ return min(len, n);
+}
+#endif
+
+/******************************************************************************/
+/*
* Add a character to a string buffer
*/
@@ -527,13 +551,13 @@ static void put_ulong(strbuf_t *buf, unsigned long int value, int base,
char_t *ascToUni(char_t *ubuf, char *str, int nBytes)
{
-#if UNICODE
+#ifdef UNICODE
if (MultiByteToWideChar(CP_ACP, 0, str, nBytes / sizeof(char_t), ubuf,
nBytes / sizeof(char_t)) < 0) {
return (char_t*) str;
}
#else
- memcpy(ubuf, str, nBytes);
+ strncpy(ubuf, str, nBytes);
#endif
return ubuf;
}
@@ -547,13 +571,13 @@ char_t *ascToUni(char_t *ubuf, char *str, int nBytes)
char *uniToAsc(char *buf, char_t *ustr, int nBytes)
{
-#if UNICODE
+#ifdef UNICODE
if (WideCharToMultiByte(CP_ACP, 0, ustr, nBytes, buf, nBytes, NULL,
NULL) < 0) {
return (char*) ustr;
}
#else
- memcpy(buf, ustr, nBytes);
+ strncpy(buf, ustr, nBytes);
#endif
return (char*) buf;
}
diff --git a/c/src/libnetworking/rtems_webserver/ringq.c b/c/src/libnetworking/rtems_webserver/ringq.c
index cd483ae007..efb9c45a70 100644
--- a/c/src/libnetworking/rtems_webserver/ringq.c
+++ b/c/src/libnetworking/rtems_webserver/ringq.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -47,7 +49,7 @@
/********************************* Includes ***********************************/
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
@@ -245,7 +247,7 @@ void ringqAddNull(ringq_t *rq)
}
/******************************************************************************/
-#if UNICODE
+#ifdef UNICODE
/*
* Get a byte from the queue
*/
@@ -538,7 +540,7 @@ static int ringqGrow(ringq_t *rq)
ringqGetBlk(rq, newbuf, ringqLen(rq));
bfree(B_L, (char*) rq->buf);
-#if OLD
+#ifdef OLD
rq->endp = &newbuf[endp];
rq->servp = &newbuf[servp];
rq->endbuf = &newbuf[rq->buflen];
diff --git a/c/src/libnetworking/rtems_webserver/rom.c b/c/src/libnetworking/rtems_webserver/rom.c
index 6bb8a8da99..f9ff5312ac 100644
--- a/c/src/libnetworking/rtems_webserver/rom.c
+++ b/c/src/libnetworking/rtems_webserver/rom.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -24,7 +26,7 @@
/******************************** Local Data **********************************/
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
sym_fd_t romTab; /* Symbol table for web pages */
diff --git a/c/src/libnetworking/rtems_webserver/security.c b/c/src/libnetworking/rtems_webserver/security.c
index f4579ad41e..e80e2aeae4 100644
--- a/c/src/libnetworking/rtems_webserver/security.c
+++ b/c/src/libnetworking/rtems_webserver/security.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -81,10 +83,14 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
*/
#ifdef WEBS_SSL_SUPPORT
nRet = umGetAccessLimitSecure(accessLimit);
- if (nRet && ((flags | WEBS_SECURE) == 0)) {
+ if (nRet && ((flags & WEBS_SECURE) == 0)) {
websStats.access++;
- websError(wp, 200, T("Access Denied\nSecure access is required."));
+ websError(wp, 405, T("Access Denied\nSecure access is required."));
trace(3, T("SEC: Non-secure access attempted on <%s>\n"), path);
+ /* bugfix 5/24/02 -- we were leaking the memory pointed to by
+ * 'accessLimit'. Thanks to Simon Byholm.
+ */
+ bfree(B_L, accessLimit);
return 1;
}
#endif
@@ -109,7 +115,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
} else if (userid && *userid) {
if (!umUserExists(userid)) {
websStats.access++;
- websError(wp, 200, T("Access Denied\nUnknown User"));
+ websError(wp, 401, T("Access Denied\nUnknown User"));
trace(3, T("SEC: Unknown user <%s> attempted to access <%s>\n"),
userid, path);
nRet = 1;
@@ -122,7 +128,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
if (userpass) {
if (gstrcmp(password, userpass) != 0) {
websStats.access++;
- websError(wp, 200, T("Access Denied\nWrong Password"));
+ websError(wp, 401, T("Access Denied\nWrong Password"));
trace(3, T("SEC: Password fail for user <%s>")
T("attempt to access <%s>\n"), userid, path);
nRet = 1;
@@ -153,7 +159,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
if (gstrcmp(wp->digest, digestCalc) != 0) {
websStats.access++;
- websError(wp, 200, T("Access Denied\nWrong Password"));
+ websError(wp, 405, T("Access Denied\nWrong Password"));
nRet = 1;
}
diff --git a/c/src/libnetworking/rtems_webserver/sock.c b/c/src/libnetworking/rtems_webserver/sock.c
index f23a63984f..7c603230a8 100644
--- a/c/src/libnetworking/rtems_webserver/sock.c
+++ b/c/src/libnetworking/rtems_webserver/sock.c
@@ -2,6 +2,8 @@
* sock.c -- Posix Socket upper layer support module for general posix use
*
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -16,7 +18,7 @@
#include <string.h>
#include <stdlib.h>
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include <socket.h>
@@ -70,7 +72,7 @@ int socketWrite(int sid, char *buf, int bufsize)
}
if ((room = ringqPutBlkMax(rq)) == 0) {
if (sp->flags & SOCKET_BLOCK) {
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
int errCode;
if (! socketWaitForEvent(sp, FD_WRITE | SOCKET_WRITABLE,
&errCode)) {
@@ -99,7 +101,7 @@ int socketWrite(int sid, char *buf, int bufsize)
int socketWriteString(int sid, char_t *buf)
{
- #if UNICODE
+ #ifdef UNICODE
char *byteBuf;
int r, len;
@@ -247,7 +249,7 @@ int socketGets(int sid, char_t **buf)
if (c == '\n') {
len = ringqLen(lq);
if (len > 0) {
- *buf = ballocAscToUni(lq->servp, len);
+ *buf = ballocAscToUni((char *)lq->servp, len);
} else {
*buf = NULL;
}
@@ -298,7 +300,7 @@ int socketFlush(int sid)
if (errCode == EINTR) {
continue;
} else if (errCode == EWOULDBLOCK || errCode == EAGAIN) {
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
if (sp->flags & SOCKET_BLOCK) {
int errCode;
if (! socketWaitForEvent(sp, FD_WRITE | SOCKET_WRITABLE,
@@ -478,7 +480,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
*errCode = 0;
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
if ((sp->flags & SOCKET_ASYNC)
&& ! socketWaitForEvent(sp, FD_CONNECT, errCode)) {
return -1;
@@ -490,7 +492,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
*/
if (sp->flags & SOCKET_BROADCAST) {
server.sin_family = AF_INET;
-#if UEMF || LITTLEFOOT
+#if (defined (UEMF) || defined (LITTLEFOOT))
server.sin_addr.s_addr = INADDR_BROADCAST;
#else
server.sin_addr.s_addr = inet_addr(basicGetBroadcastAddress());
@@ -514,7 +516,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
if (bytes < 0) {
*errCode = socketGetError();
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
sp->currentEvents &= ~FD_WRITE;
#endif
@@ -522,7 +524,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
} else if (bytes == 0 && bytes != toWrite) {
*errCode = EWOULDBLOCK;
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
sp->currentEvents &= ~FD_WRITE;
#endif
return -1;
@@ -532,8 +534,8 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
* Ensure we get to write some more data real soon if the socket can absorb
* more data
*/
-#if !UEMF
-#if WIN
+#ifndef UEMF
+#ifdef WIN
if (sp->interestEvents & FD_WRITE) {
emfTime_t blockTime = { 0, 0 };
emfSetMaxBlockTime(&blockTime);
@@ -553,7 +555,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
static int tryAlternateSendTo(int sock, char *buf, int toWrite, int i,
struct sockaddr *server)
{
-#if VXWORKS
+#ifdef VXWORKS
char *ptr;
ptr = (char *)server;
@@ -638,7 +640,7 @@ void socketFree(int sid)
if (shutdown(sp->sock, 1) >= 0) {
recv(sp->sock, buf, sizeof(buf), 0);
}
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
closesocket(sp->sock);
#else
close(sp->sock);
@@ -688,7 +690,7 @@ socket_t *socketPtr(int sid)
int socketGetError()
{
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
switch (WSAGetLastError()) {
case WSAEWOULDBLOCK:
return EWOULDBLOCK;
diff --git a/c/src/libnetworking/rtems_webserver/sym.c b/c/src/libnetworking/rtems_webserver/sym.c
index cc06cffe2a..35e6ff8299 100644
--- a/c/src/libnetworking/rtems_webserver/sym.c
+++ b/c/src/libnetworking/rtems_webserver/sym.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -16,7 +18,7 @@
/********************************* Includes ***********************************/
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
diff --git a/c/src/libnetworking/rtems_webserver/uemf.c b/c/src/libnetworking/rtems_webserver/uemf.c
index aa177849a2..ffe6a04cd1 100644
--- a/c/src/libnetworking/rtems_webserver/uemf.c
+++ b/c/src/libnetworking/rtems_webserver/uemf.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/********************************** Description *******************************/
@@ -46,14 +48,24 @@ void error(E_ARGS_DEC, int etype, char_t *fmt, ...)
if (etype == E_LOG) {
fmtAlloc(&buf, E_MAX_ERROR, T("%s\n"), fmtBuf);
-#if DEV
+/*#ifdef DEV*/
} else if (etype == E_ASSERT) {
fmtAlloc(&buf, E_MAX_ERROR,
T("Assertion %s, failed at %s %d\n"), fmtBuf, E_ARGS);
-#endif
+/*#endif*/
} else if (etype == E_USER) {
fmtAlloc(&buf, E_MAX_ERROR, T("%s\n"), fmtBuf);
}
+ /*
+ * bugfix -- if etype is not E_LOG, E_ASSERT, or E_USER, the call to
+ * bfreeSafe(B_L, buf) below will fail, because 'buf' is randomly
+ * initialized. To be nice, we format a message saying that this is an
+ * unknown message type, and in doing so give buf a valid value. Thanks
+ * to Simon Byholm.
+ */
+ else {
+ fmtAlloc(&buf, E_MAX_ERROR, T("Unknown error"));
+ }
va_end(args);
bfree(B_L, fmtBuf);
diff --git a/c/src/libnetworking/rtems_webserver/uemf.h b/c/src/libnetworking/rtems_webserver/uemf.h
index b695633ec3..19eb9f559d 100644
--- a/c/src/libnetworking/rtems_webserver/uemf.h
+++ b/c/src/libnetworking/rtems_webserver/uemf.h
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
#ifndef _h_UEMF
@@ -17,7 +19,7 @@
/******************************* Per O/S Includes *****************************/
-#if WIN
+#ifdef WIN
#include <direct.h>
#include <io.h>
#include <sys/stat.h>
@@ -33,20 +35,43 @@
#include <errno.h>
#endif /* WIN */
-#if CE
+#ifdef CE
+ #include <errno.h>
#include <limits.h>
#include <tchar.h>
#include <windows.h>
+ #include <winsock.h>
#include <winnls.h>
#include "CE/wincompat.h"
#include <winsock.h>
#endif /* CE */
-#if NW
+#ifdef NW
+ #include <direct.h>
+ #include <io.h>
+ #include <sys/stat.h>
+ #include <time.h>
+ #include <sys/types.h>
#include <stdio.h>
+ #include <stdlib.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <niterror.h>
+ #define EINTR EINUSE
+ #define WEBS 1
+ #include <limits.h>
+ #include <netdb.h>
+ #include <process.h>
+ #include <tiuser.h>
+ #include <sys/time.h>
+ #include <arpa/inet.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/filio.h>
+ #include <netinet/in.h>
#endif /* NW */
-#if SCOV5
+#ifdef SCOV5
#include <sys/types.h>
#include <stdio.h>
#include "sys/socket.h"
@@ -56,7 +81,7 @@
#include "netdb.h"
#endif /* SCOV5 */
-#if UNIX
+#ifdef UNIX
#include <stdio.h>
#endif /* UNIX */
@@ -78,7 +103,7 @@
#include <errno.h>
#endif /* LINUX */
-#if LYNX
+#ifdef LYNX
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
@@ -93,11 +118,24 @@
#include <errno.h>
#endif /* LYNX */
-#if UW
+#ifdef MACOSX
+ #include <sys/stat.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ #include <fcntl.h>
+ #include <errno.h>
+#endif /* MACOSX */
+
+#ifdef UW
#include <stdio.h>
#endif /* UW */
-#if VXWORKS
+#ifdef VXWORKS
#include <vxWorks.h>
#include <sockLib.h>
#include <selectLib.h>
@@ -111,7 +149,7 @@
#include <errno.h>
#endif /* VXWORKS */
-#if SOLARIS
+#ifdef SOLARIS
#include <sys/types.h>
#include <limits.h>
#include <stdio.h>
@@ -127,7 +165,7 @@
#include <errno.h>
#endif /* SOLARIS */
-#if QNX4
+#ifdef QNX4
#include <sys/types.h>
#include <stdio.h>
#include <sys/socket.h>
@@ -141,7 +179,7 @@
#include <sys/wait.h>
#endif /* QNX4 */
-#if ECOS
+#ifdef ECOS
#include <limits.h>
#include <cyg/infra/cyg_type.h>
#include <cyg/kernel/kapi.h>
@@ -156,7 +194,7 @@
#include <stdarg.h>
#include <string.h>
-#if ! WEBS
+#ifndef WEBS
#include "messages.h"
#endif /* ! WEBS */
@@ -166,18 +204,18 @@
#define __NO_PACK 1
#endif
-#if UW
+#ifdef UW
#define __NO_PACK 1
#endif /* UW */
-#if SCOV5 || VXWORKS || LINUX || LYNX || __rtems__
+#if (defined (SCOV5) || defined (VXWORKS) || defined (LINUX) || defined (LYNX) || defined (MACOSX) || defined (__rtems__))
#ifndef O_BINARY
#define O_BINARY 0
#endif /* O_BINARY */
#define SOCKET_ERROR -1
-#endif /* SCOV5 || VXWORKS || LINUX || LYNX */
+#endif /* SCOV5 || VXWORKS || LINUX || LYNX || MACOSX */
-#if WIN || CE
+#if (defined (WIN) || defined (CE))
/*
* __NO_FCNTL means can't access fcntl function. Fcntl.h is still available.
*/
@@ -193,7 +231,7 @@
#define F_OK 0
#endif /* WIN || CE */
-#if LINUX && !__rtems__ && ! _STRUCT_TIMEVAL
+#if (defined (LINUX) && !defined(__rtems__) && !defined (_STRUCT_TIMEVAL))
struct timeval
{
time_t tv_sec; /* Seconds. */
@@ -202,7 +240,7 @@ struct timeval
#define _STRUCT_TIMEVAL 1
#endif /* LINUX && ! _STRUCT_TIMEVAL */
-#if ECOS
+#ifdef ECOS
#define O_RDONLY 1
#define O_BINARY 2
@@ -218,11 +256,28 @@ struct timeval
#endif /* ECOS */
-#if QNX4
+#ifdef QNX4
typedef long fd_mask;
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
#endif /* QNX4 */
+#ifdef NW
+ #define fd_mask fd_set
+ #define INADDR_NONE -1l
+ #define Sleep delay
+
+ #define __NO_FCNTL 1
+
+ #undef R_OK
+ #define R_OK 4
+ #undef W_OK
+ #define W_OK 2
+ #undef X_OK
+ #define X_OK 1
+ #undef F_OK
+ #define F_OK 0
+#endif /* NW */
+
/********************************** Unicode ***********************************/
/*
* Constants and limits. Also FNAMESIZE and PATHSIZE are currently defined
@@ -233,8 +288,9 @@ struct timeval
#define SYM_MAX (512)
#define XML_MAX 4096 /* Maximum size for tags/tokens */
#define BUF_MAX 4096 /* General sanity check for bufs */
+#define FMT_STATIC_MAX 256 /* Maximum for fmtStatic calls */
-#if LITTLEFOOT || WEBS
+#if (defined (LITTLEFOOT) || defined (WEBS))
#define LF_BUF_MAX (510)
#define LF_PATHSIZE LF_BUF_MAX
#else
@@ -245,7 +301,7 @@ struct timeval
#ifndef CHAR_T_DEFINED
#define CHAR_T_DEFINED 1
-#if UNICODE
+#ifdef UNICODE
/*
* To convert strings to UNICODE. We have a level of indirection so things
* like T(__FILE__) will expand properly.
@@ -271,7 +327,7 @@ typedef unsigned short uchar_t;
typedef char char_t;
#define TSZ(x) (sizeof(x))
#define TASTRL(x) (strlen(x) + 1)
-#if WIN
+#ifdef WIN
typedef unsigned char uchar_t;
#endif /* WIN */
@@ -301,14 +357,14 @@ typedef unsigned char uchar_t;
* The following include has to be after the unicode defines. By putting it
* here, many modules in various parts of the tree are cleaner.
*/
-#if LITTLEFOOT && INMEM
+#if (defined (LITTLEFOOT) && defined (INMEM))
#include "lf/inmem.h"
#endif /* LITTLEFOOT && INMEM */
/*
* Type for unicode systems
*/
-#if UNICODE
+#ifdef UNICODE
#define gmain wmain
@@ -367,7 +423,7 @@ typedef struct _stat gstat_t;
#define gtolower towlower
#define gtoupper towupper
-#if CE
+#ifdef CE
#define gisspace isspace
#define gisdigit isdigit
#define gisxdigit isxdigit
@@ -394,39 +450,39 @@ typedef struct _stat gstat_t;
#ifndef gopen
#if INMEM
+#define gchdir imChdir
+#define gmkdir imMkdir
+#define grmdir imRmdir
#define gclose imClose
#define gclosedir imClosedir
-#define gchdir imChdir
#define gchmod imChmod
#define ggetcwd imGetcwd
#define glseek imLseek
#define gloadModule imLoadModule
-#define gmkdir imMkdir
#define gopen imOpen
#define gopendir imOpendir
#define gread imRead
#define greaddir imReaddir
#define grename imRename
-#define grmdir imRmdir
#define gstat imStat
#define gunlink imUnlink
#define gwrite imWrite
#else
-#define gclose close
-#define gclosedir closedir
#if VXWORKS
#define gchdir vxchdir
#define gmkdir vxmkdir
#define grmdir vxrmdir
-#else
-#if LYNX || LINUX || SOLARIS
+#elif (defined (LYNX) || defined (LINUX) || defined (MACOSX) || defined (SOLARIS))
+#define gchdir chdir
#define gmkdir(s) mkdir(s,0755)
+#define grmdir rmdir
#else
+#define gchdir chdir
#define gmkdir mkdir
-#endif /* LYNX || LINUX || SOLARIS */
#define grmdir rmdir
-#define gchdir chdir
-#endif /* VXWORKS */
+#endif /* VXWORKS #elif LYNX || LINUX || MACOSX || SOLARIS*/
+#define gclose close
+#define gclosedir closedir
#define gchmod chmod
#define ggetcwd getcwd
#define glseek lseek
@@ -500,11 +556,19 @@ typedef struct stat gstat_t;
#ifndef VXWORKS
#define gmain main
#endif /* ! VXWORKS */
-#if VXWORKS
+#ifdef VXWORKS
#define fcntl(a, b, c)
#endif /* VXWORKS */
#endif /* ! UNICODE */
+/*
+ * Include inmem.h here because it redefines many of the file access fucntions.
+ * Otherwise there would be lots more #if-#elif-#else-#endif ugliness.
+ */
+#ifdef INMEM
+ #include "lf/inmem.h"
+#endif
+
/********************************** Defines ***********************************/
#ifndef FNAMESIZE
@@ -525,7 +589,7 @@ typedef struct stat gstat_t;
#define E_ARGS_DEC char_t *file, int line
#define E_ARGS file, line
-#if ASSERT || ASSERT_CE
+#if (defined (ASSERT) || defined (ASSERT_CE))
#define a_assert(C) if (C) ; else error(E_L, E_ASSERT, T("%s"), T(#C))
#else
#define a_assert(C) if (1) ; else
@@ -570,7 +634,7 @@ typedef struct {
long hex;
long octal;
long big[2];
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
double floating;
#endif /* FLOATING_POINT_SUPPORT */
char_t *string;
@@ -579,7 +643,7 @@ typedef struct {
void *symbol;
} value;
- vtype_t type : 16;
+ vtype_t type;
unsigned int valid : 8;
unsigned int allocated : 8; /* String was balloced */
} value_t;
@@ -749,47 +813,48 @@ extern int cronFree(cron_t *cp);
* Socket flags
*/
-#if (WIN || CE) && WEBS
+#if ((defined (WIN) || defined (CE)) && defined (WEBS))
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ENETDOWN WSAENETDOWN
#define ECONNRESET WSAECONNRESET
#endif /* (WIN || CE) && WEBS) */
-#define SOCKET_EOF 0x1 /* Seen end of file */
-#define SOCKET_CONNECTING 0x2 /* Connect in progress */
-#define SOCKET_BROADCAST 0x4 /* Broadcast mode */
-#define SOCKET_PENDING 0x8 /* Message pending on this socket */
-#define SOCKET_FLUSHING 0x10 /* Background flushing */
-#define SOCKET_DATAGRAM 0x20 /* Use datagrams */
-#define SOCKET_ASYNC 0x40 /* Use async connect */
-#define SOCKET_BLOCK 0x80 /* Use blocking I/O */
-#define SOCKET_LISTENING 0x100 /* Socket is server listener */
-#define SOCKET_CLOSING 0x200 /* Socket is closing */
+#define SOCKET_EOF 0x1 /* Seen end of file */
+#define SOCKET_CONNECTING 0x2 /* Connect in progress */
+#define SOCKET_BROADCAST 0x4 /* Broadcast mode */
+#define SOCKET_PENDING 0x8 /* Message pending on this socket */
+#define SOCKET_FLUSHING 0x10 /* Background flushing */
+#define SOCKET_DATAGRAM 0x20 /* Use datagrams */
+#define SOCKET_ASYNC 0x40 /* Use async connect */
+#define SOCKET_BLOCK 0x80 /* Use blocking I/O */
+#define SOCKET_LISTENING 0x100 /* Socket is server listener */
+#define SOCKET_CLOSING 0x200 /* Socket is closing */
+#define SOCKET_CONNRESET 0x400 /* Socket connection was reset */
-#define SOCKET_PORT_MAX 0xffff /* Max Port size */
+#define SOCKET_PORT_MAX 0xffff /* Max Port size */
/*
* Socket error values
*/
-#define SOCKET_WOULDBLOCK 1 /* Socket would block on I/O */
-#define SOCKET_RESET 2 /* Socket has been reset */
-#define SOCKET_NETDOWN 3 /* Network is down */
-#define SOCKET_AGAIN 4 /* Issue the request again */
-#define SOCKET_INTR 5 /* Call was interrupted */
-#define SOCKET_INVAL 6 /* Invalid */
+#define SOCKET_WOULDBLOCK 1 /* Socket would block on I/O */
+#define SOCKET_RESET 2 /* Socket has been reset */
+#define SOCKET_NETDOWN 3 /* Network is down */
+#define SOCKET_AGAIN 4 /* Issue the request again */
+#define SOCKET_INTR 5 /* Call was interrupted */
+#define SOCKET_INVAL 6 /* Invalid */
/*
* Handler event masks
*/
-#define SOCKET_READABLE 0x2 /* Make socket readable */
-#define SOCKET_WRITABLE 0x4 /* Make socket writable */
-#define SOCKET_EXCEPTION 0x8 /* Interested in exceptions */
+#define SOCKET_READABLE 0x2 /* Make socket readable */
+#define SOCKET_WRITABLE 0x4 /* Make socket writable */
+#define SOCKET_EXCEPTION 0x8 /* Interested in exceptions */
#define EMF_SOCKET_MESSAGE (WM_USER+13)
-#if LITTLEFOOT
-#define SOCKET_BUFSIZ 510 /* Underlying buffer size */
+#ifdef LITTLEFOOT
+#define SOCKET_BUFSIZ 510 /* Underlying buffer size */
#else
-#define SOCKET_BUFSIZ 1024 /* Underlying buffer size */
+#define SOCKET_BUFSIZ 1024 /* Underlying buffer size */
#endif /* LITTLEFOOT */
typedef void (*socketHandler_t)(int sid, int mask, int data);
@@ -830,7 +895,7 @@ extern int bopen(void *buf, int bufsize, int flags);
* #define NO_BALLOC 1
*/
-#if NO_BALLOC
+#ifdef NO_BALLOC
#define balloc(B_ARGS, num) malloc(num)
#define bfree(B_ARGS, p) free(p)
#define bfreeSafe(B_ARGS, p) \
@@ -851,7 +916,7 @@ extern char *bstrdupANoBalloc(char *s);
#define brealloc(B_ARGS, p, size) brealloc(p, size)
#define bstrdup(B_ARGS, p) bstrdup(p)
-#if UNICODE
+#ifdef UNICODE
#define bstrdupA(B_ARGS, p) bstrdupA(p)
#else /* UNICODE */
#define bstrdupA bstrdup
@@ -866,7 +931,7 @@ extern void bfreeSafe(B_ARGS_DEC, void *mp);
extern void *brealloc(B_ARGS_DEC, void *buf, int newsize);
extern char_t *bstrdup(B_ARGS_DEC, char_t *s);
-#if UNICODE
+#ifdef UNICODE
extern char *bstrdupA(B_ARGS_DEC, char *s);
#else /* UNICODE */
#define bstrdupA bstrdup
@@ -881,11 +946,12 @@ extern void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...));
#define B_USE_MALLOC 0x1 /* Okay to use malloc if required */
#define B_USER_BUF 0x2 /* User supplied buffer for mem */
+
#if !LINUX && !__rtems__
extern char_t *basename(char_t *name);
#endif /* !LINUX */
-#if UEMF && WEBS
+#if (defined (UEMF) && defined (WEBS))
/*
* The open source webserver uses a different callback/timer mechanism
* than other emf derivative products such as FieldUpgrader agents
@@ -908,7 +974,7 @@ extern void error(E_ARGS_DEC, int flags, char_t *fmt, ...);
extern void (*errorSetHandler(void (*function)(int etype, char_t *msg))) \
(int etype, char_t *msg);
-#if B_STATS
+#ifdef B_STATS
#define hAlloc(x) HALLOC(B_L, x)
#define hAllocEntry(x, y, z) HALLOCENTRY(B_L, x, y, z)
extern int HALLOC(B_ARGS_DEC, void ***map);
@@ -933,7 +999,7 @@ extern int fmtValloc(char_t **s, int n, char_t *fmt, va_list arg);
extern int fmtAlloc(char_t **s, int n, char_t *fmt, ...);
extern int fmtStatic(char_t *s, int n, char_t *fmt, ...);
-#if UNICODE
+#ifdef UNICODE
extern int ringqPutcA(ringq_t *rq, char c);
extern int ringqInsertcA(ringq_t *rq, char c);
extern int ringqPutStrA(ringq_t *rq, char *str);
diff --git a/c/src/libnetworking/rtems_webserver/um.c b/c/src/libnetworking/rtems_webserver/um.c
index ce9e171c01..e960f02719 100644
--- a/c/src/libnetworking/rtems_webserver/um.c
+++ b/c/src/libnetworking/rtems_webserver/um.c
@@ -53,6 +53,13 @@
/******************************** Local Data **********************************/
+#ifdef qHierarchicalAccess
+/*
+ * user-provided function to allow hierarchical access protection. See below.
+ * for details.
+ */
+extern bool_t dmfCanAccess(const char_t* usergroup, const char_t* group);
+#endif
#ifdef UEMF
/*
* User table definition
@@ -1377,15 +1384,28 @@ bool_t umUserCanAccessURL(char_t *user, char_t *url)
* member of that group
*/
if (group && *group) {
+#ifdef qHierarchicalAccess
+ /*
+ * If we are compiling with the hierarchical access extensions, we
+ * instead call the user-provided function that checks to see whether
+ * the current user's access level is greater than or equal to the
+ * access level required for this URL.
+ */
+ return dmfCanAccess(usergroup, group);
+
+#else
if (usergroup && (gstrcmp(group, usergroup) != 0)) {
return FALSE;
+
}
+#endif
}
/*
* Otherwise, user can access the URL
*/
return TRUE;
+
}
/******************************************************************************/
diff --git a/c/src/libnetworking/rtems_webserver/um.h b/c/src/libnetworking/rtems_webserver/um.h
index d44fa28e91..bdef4906fe 100644
--- a/c/src/libnetworking/rtems_webserver/um.h
+++ b/c/src/libnetworking/rtems_webserver/um.h
@@ -21,7 +21,7 @@
/********************************* Includes ***********************************/
-#if ! UEMF
+#ifndef UEMF
#include "basic/basic.h"
#include "emf/emf.h"
#else
diff --git a/c/src/libnetworking/rtems_webserver/url.c b/c/src/libnetworking/rtems_webserver/url.c
index 0258387c59..07a99cc843 100644
--- a/c/src/libnetworking/rtems_webserver/url.c
+++ b/c/src/libnetworking/rtems_webserver/url.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
diff --git a/c/src/libnetworking/rtems_webserver/value.c b/c/src/libnetworking/rtems_webserver/value.c
index 97dba81633..ac21ec6afe 100644
--- a/c/src/libnetworking/rtems_webserver/value.c
+++ b/c/src/libnetworking/rtems_webserver/value.c
@@ -2,6 +2,8 @@
* value.c -- Generic type (holds all types)
*
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -13,14 +15,14 @@
/********************************* Includes ***********************************/
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#else
#include "basic/basicInternal.h"
#endif
/*********************************** Locals ***********************************/
-#if !UEMF
+#ifndef UEMF
static value_t value_null; /* All zeros */
/***************************** Forward Declarations ***************************/
@@ -77,7 +79,7 @@ void valueFree(value_t* v)
v->value.string != NULL) {
bfree(B_L, v->value.string);
}
-#if !UEMF
+#ifndef UEMF
if (v->valid && v->type == symbol && v->value.symbol.data != NULL &&
v->value.symbol.freeCb !=NULL) {
v->value.symbol.freeCb(v->value.symbol.data);
@@ -88,7 +90,7 @@ void valueFree(value_t* v)
v->allocated = 0;
}
-#if !UEMF
+#ifndef UEMF
/******************************************************************************/
/*
@@ -151,7 +153,7 @@ value_t valueShortint(short value)
return v;
}
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
/******************************************************************************/
/*
* Initialize a floating value.
@@ -336,7 +338,7 @@ value_t valueAdd(value_t v1, value_t v2)
a_assert(0);
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
v1.value.floating += v2.value.floating;
return v1;
@@ -393,7 +395,7 @@ value_t valueSub(value_t v1, value_t v2)
a_assert(0);
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
v1.value.floating -= v2.value.floating;
return v1;
@@ -454,7 +456,7 @@ value_t valueMul(value_t v1, value_t v2)
a_assert(v1.type != flag);
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
v1.value.floating *= v2.value.floating;
return v1;
@@ -511,7 +513,7 @@ value_t valueDiv(value_t v1, value_t v2)
a_assert(v1.type != flag);
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
v1.value.floating /= v2.value.floating;
return v1;
@@ -582,7 +584,7 @@ int valueCmp(value_t v1, value_t v2)
return 0;
else return 1;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
if (v1.value.floating < v2.value.floating)
return -1;
@@ -633,7 +635,7 @@ int valueCmp(value_t v1, value_t v2)
static void coerce_types(register value_t* v1, register value_t* v2)
{
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
if (v1->type == floating) {
v2->type = floating;
v2->value.floating = (double) v2->value.integer;
@@ -700,7 +702,7 @@ int valueNegative(value_t* vp)
case bytes:
return 0;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
if (vp->value.floating < 0)
return 1;
@@ -750,7 +752,7 @@ int valueZero(value_t* vp)
case bytes:
return 0;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
if (vp->value.floating == 0)
return 1;
@@ -801,7 +803,7 @@ static int value_to_integer(value_t* vp)
case string:
case bytes:
case big:
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
a_assert(0);
return -1;
@@ -852,7 +854,7 @@ void valueSprintf(char_t** out, int size, char_t* fmt, value_t vp)
}
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
if (fmt == NULL || *fmt == '\0') {
fmtAlloc(out, size, T("%f"), vp.value.floating);
@@ -961,7 +963,7 @@ void valueSprintf(char_t** out, int size, char_t* fmt, value_t vp)
}
break;
-#if UNUSED
+#ifdef UNUSED
case bytes:
asrc = vp.value.bytes;
@@ -1168,7 +1170,7 @@ value_t valueAtov(char_t* s, int pref_type)
}
break;
-#if FLOATING_POINT_SUPPORT
+#ifdef FLOATING_POINT_SUPPORT
case floating:
gsscanf(s, T("%f"), &v.value.floating);
break;
@@ -1191,7 +1193,7 @@ value_t valueAtov(char_t* s, int pref_type)
v = valueBytes((char*) s, VALUE_ALLOCATE);
break;
-#if UNUSED
+#ifdef UNUSED
case literal:
v = value_literal(bstrdup(B_L, s));
v.value.literal[len] = '\0';
diff --git a/c/src/libnetworking/rtems_webserver/wbase64.c b/c/src/libnetworking/rtems_webserver/wbase64.c
index b1eb6b01c5..87659eeb6a 100644
--- a/c/src/libnetworking/rtems_webserver/wbase64.c
+++ b/c/src/libnetworking/rtems_webserver/wbase64.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
diff --git a/c/src/libnetworking/rtems_webserver/webcomp.c b/c/src/libnetworking/rtems_webserver/webcomp.c
index 575f4be46b..6b19b3ba18 100644
--- a/c/src/libnetworking/rtems_webserver/webcomp.c
+++ b/c/src/libnetworking/rtems_webserver/webcomp.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -112,7 +114,7 @@ static int compile(char_t *fileList, char_t *prefix)
fprintf(stderr, "Can't open file %s\n", file);
return -1;
}
- fprintf(stdout, "static const unsigned char page_%d[] = {\n", nFile);
+ fprintf(stdout, "static unsigned char page_%d[] = {\n", nFile);
while ((len = read(fd, buf, sizeof(buf))) > 0) {
p = buf;
diff --git a/c/src/libnetworking/rtems_webserver/webpage.c b/c/src/libnetworking/rtems_webserver/webpage.c
index efac13f508..b161740738 100644
--- a/c/src/libnetworking/rtems_webserver/webpage.c
+++ b/c/src/libnetworking/rtems_webserver/webpage.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/******************************** Description *********************************/
@@ -27,7 +29,7 @@ int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm)
{
a_assert(websValid(wp));
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
return websRomPageOpen(wp, path, mode, perm);
#else
return (wp->docfd = gopen(lpath, mode, perm));
@@ -43,7 +45,7 @@ void websPageClose(webs_t wp)
{
a_assert(websValid(wp));
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
websRomPageClose(wp->docfd);
#else
if (wp->docfd >= 0) {
@@ -60,7 +62,7 @@ void websPageClose(webs_t wp)
int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
{
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
return websRomPageStat(path, sbuf);
#else
gstat_t s;
@@ -82,7 +84,7 @@ int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
int websPageIsDirectory(char_t *lpath)
{
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
websStatType sbuf;
if (websRomPageStat(lpath, &sbuf) >= 0) {
@@ -111,7 +113,7 @@ int websPageIsDirectory(char_t *lpath)
int websPageReadData(webs_t wp, char *buf, int nBytes)
{
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
a_assert(websValid(wp));
return websRomPageReadData(wp, buf, nBytes);
#else
@@ -129,7 +131,7 @@ void websPageSeek(webs_t wp, long offset)
{
a_assert(websValid(wp));
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
websRomPageSeek(wp, offset, SEEK_CUR);
#else
lseek(wp->docfd, offset, SEEK_CUR);
diff --git a/c/src/libnetworking/rtems_webserver/webrom.c b/c/src/libnetworking/rtems_webserver/webrom.c
index 61d795949e..23de2c6d60 100644
--- a/c/src/libnetworking/rtems_webserver/webrom.c
+++ b/c/src/libnetworking/rtems_webserver/webrom.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
#include "wsIntrn.h"
diff --git a/c/src/libnetworking/rtems_webserver/webs.c b/c/src/libnetworking/rtems_webserver/webs.c
index 3181c602ec..ae6730dfb2 100644
--- a/c/src/libnetworking/rtems_webserver/webs.c
+++ b/c/src/libnetworking/rtems_webserver/webs.c
@@ -19,7 +19,7 @@
#include "wsIntrn.h"
#ifdef DIGEST_ACCESS_SUPPORT
-#include "websda.h"
+ #include "websda.h"
#endif
/******************************** Global Data *********************************/
@@ -44,7 +44,7 @@ websErrorType websErrors[] = {
{ 204, T("No Content") },
{ 301, T("Redirect") },
{ 302, T("Redirect") },
- { 304, T("User local copy") },
+ { 304, T("Use local copy") },
{ 400, T("Page not found") },
{ 401, T("Unauthorized") },
{ 403, T("Forbidden") },
@@ -56,7 +56,7 @@ websErrorType websErrors[] = {
{ 0, NULL }
};
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
static char_t websLogname[64] = T("log.txt"); /* Log filename */
static int websLogFd; /* Log file handle */
#endif
@@ -69,17 +69,17 @@ static int websOpenCount = 0; /* count of apps using this module */
/**************************** Forward Declarations ****************************/
-static char_t *websErrorMsg(int code);
+/*static char_t *websErrorMsg(int code);*/
static int websGetInput(webs_t wp, char_t **ptext, int *nbytes);
static int websParseFirst(webs_t wp, char_t *text);
static void websParseRequest(webs_t wp);
static void websSocketEvent(int sid, int mask, int data);
static int websGetTimeSinceMark(webs_t wp);
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
static void websLog(webs_t wp, int code);
#endif
-#if WEBS_IF_MODIFIED_SUPPORT
+#ifdef WEBS_IF_MODIFIED_SUPPORT
static time_t dateParse(time_t tip, char_t *cmd);
#endif
@@ -99,7 +99,7 @@ int websOpenServer(int port, int retries)
a_assert(port > 0);
a_assert(retries >= 0);
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
websRomOpen();
#endif
@@ -123,7 +123,7 @@ int websOpenServer(int port, int retries)
}
websFormOpen();
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
/*
* Optional request log support
*/
@@ -165,14 +165,14 @@ void websCloseServer()
websFree(wp);
}
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
if (websLogFd >= 0) {
close(websLogFd);
websLogFd = -1;
}
#endif
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
websRomClose();
#endif
symClose(websMime);
@@ -272,7 +272,7 @@ int websAccept(int sid, char *ipaddr, int port, int listenSid)
a_assert(wp);
wp->listenSid = listenSid;
- ascToUni(wp->ipaddr, ipaddr, sizeof(wp->ipaddr));
+ ascToUni(wp->ipaddr, ipaddr, min(sizeof(wp->ipaddr), strlen(ipaddr) + 1));
/*
* Check if this is a request from a browser on this system. This is useful
@@ -319,7 +319,7 @@ static void websSocketEvent(int sid, int mask, int iwp)
websReadEvent(wp);
}
if (mask & SOCKET_WRITABLE) {
- if (wp->writeSocket) {
+ if (websValid(wp) && wp->writeSocket) {
(*wp->writeSocket)(wp);
}
}
@@ -340,7 +340,7 @@ void websReadEvent(webs_t wp)
a_assert(wp);
a_assert(websValid(wp));
- websMarkTime(wp);
+ websSetTimeMark(wp);
/*
* Read as many lines as possible. socketGets is called to read the header
@@ -410,8 +410,18 @@ void websReadEvent(webs_t wp)
0666);
}
gwrite(fd, text, gstrlen(text));
- gwrite(fd, T("\n"), sizeof(char_t));
+ /*
+ * NOTE that the above comment is wrong -- if the content length
+ * is set, websGetInput() does NOT use socketGets(), it uses
+ * socketRead(), so the line below that adds an additional newline
+ * is destructive.
+ */
+ /*gwrite(fd, T("\n"), sizeof(char_t));*/
+/*
+ * Line removed as per BUG02488
+ *
nbytes += 1;
+ */
} else
#endif
if (wp->query) {
@@ -433,12 +443,15 @@ void websReadEvent(webs_t wp)
* The existing query data came from the POST request so just
* append it.
*/
- len = gstrlen(wp->query);
- wp->query = brealloc(B_L, wp->query, (len + gstrlen(text) +
- 1) * sizeof(char_t));
- if (wp->query) {
- gstrcpy(&wp->query[len], text);
- }
+ if (text != NULL)
+ {
+ len = gstrlen(wp->query);
+ wp->query = brealloc(B_L, wp->query, (len + gstrlen(text) +
+ 1) * sizeof(char_t));
+ if (wp->query) {
+ gstrcpy(&wp->query[len], text);
+ }
+ }
}
} else {
@@ -457,8 +470,13 @@ void websReadEvent(webs_t wp)
break;
}
/*
- * No more data so process the request
+ * No more data so process the request, (but be sure to close
+ * the input file first!).
*/
+ if (fd != -1) {
+ gclose (fd);
+ fd = -1;
+ }
websUrlHandlerRequest(wp);
done++;
break;
@@ -624,16 +642,33 @@ static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
} else {
websDone(wp, 0);
}
+ } else {
+/*
+ * If an error occurred and it wasn't an eof, close the connection
+ */
+#ifdef HP_FIX
+ websDone(wp, 0);
+#endif /*HP_FIX*/
+
}
/*
* If state is WEBS_HEADER and the ringq is empty, then this is a
* simple request with no additional header fields to process and
* no empty line terminator.
*/
+/*
+ * NOTE: this fix for earlier versions of browsers is troublesome
+ * because if we don't receive the entire header in the first pass
+ * this code assumes we were only expecting a one line header, which
+ * is not necessarily the case. So we weren't processing the whole
+ * header and weren't fufilling requests properly.
+ */
+#ifdef UNUSED
if (wp->state == WEBS_HEADER && ringqLen(&wp->header) <= 0) {
websParseRequest(wp);
websUrlHandlerRequest(wp);
}
+#endif
return -1;
} else if (nbytes == 0) {
@@ -761,7 +796,7 @@ static int websParseFirst(webs_t wp, char_t *text)
websUrlType(url, wp->type, TSZ(wp->type));
-#if WEBS_PROXY_SUPPORT
+#ifdef WEBS_PROXY_SUPPORT
/*
* Determine if this is a request for local webs data. If it is not a proxied
* request from the browser, we won't see the "http://" or the system name, so
@@ -872,6 +907,12 @@ static void websParseRequest(webs_t wp)
*/
if ((cp = gstrchr(value, ' ')) != NULL) {
*cp = '\0';
+ /*
+ * bugfix 5/24/02 -- we were leaking the memory pointed to by
+ * wp->authType that was allocated just before the if()
+ * statement that we are currently in. Thanks to Simon Byholm.
+ */
+ bfree(B_L, wp->authType);
wp->authType = bstrdup(B_L, value);
websDecode64(userAuth, ++cp, sizeof(userAuth));
} else {
@@ -1000,9 +1041,22 @@ static void websParseRequest(webs_t wp)
* Parse the content length
*/
} else if (gstrcmp(key, T("content-length")) == 0) {
- wp->flags |= WEBS_CLEN;
- wp->clen = gatoi(value);
- websSetVar(wp, T("CONTENT_LENGTH"), value);
+ /*
+ * 11 Oct 02 BgP -- The server would crash if an attacker sent a POST
+ * message with a content-length value <= 0. We assume that anyone
+ * sending this is malicious, and the POST is read from the socket,
+ * but it is ignored, and the socket is closed.
+ */
+ wp->clen = gatoi(value);
+ if (wp->clen > 0)
+ {
+ wp->flags |= WEBS_CLEN;
+ websSetVar(wp, T("CONTENT_LENGTH"), value);
+ }
+ else
+ {
+ wp->clen = 0;
+ }
/*
* Parse the content type
@@ -1010,7 +1064,7 @@ static void websParseRequest(webs_t wp)
} else if (gstrcmp(key, T("content-type")) == 0) {
websSetVar(wp, T("CONTENT_TYPE"), value);
-#if WEBS_KEEP_ALIVE_SUPPORT
+#ifdef WEBS_KEEP_ALIVE_SUPPORT
} else if (gstrcmp(key, T("connection")) == 0) {
strlower(value);
if (gstrcmp(value, T("keep-alive")) == 0) {
@@ -1018,7 +1072,7 @@ static void websParseRequest(webs_t wp)
}
#endif
-#if WEBS_PROXY_SUPPORT
+#ifdef WEBS_PROXY_SUPPORT
/*
* This may be useful if you wish to keep a local cache of web pages
* for proxied requests.
@@ -1039,7 +1093,7 @@ static void websParseRequest(webs_t wp)
wp->flags |= WEBS_COOKIE;
wp->cookie = bstrdup(B_L, value);
-#if WEBS_IF_MODIFIED_SUPPORT
+#ifdef WEBS_IF_MODIFIED_SUPPORT
/*
* See if the local page has been modified since the browser last
* requested this document. If not, just return a 302
@@ -1127,7 +1181,7 @@ void websSetEnv(webs_t wp)
keyword = gstrtok(NULL, T("&"));
}
-#if EMF
+#ifdef EMF
/*
* Add GoAhead Embedded Management Framework defines
*/
@@ -1256,7 +1310,15 @@ void websResponse(webs_t wp, int code, char_t *message, char_t *redirect)
*/
if ( !(wp->flags & WEBS_HEADER_DONE)) {
wp->flags |= WEBS_HEADER_DONE;
- websWrite(wp, T("HTTP/1.1 %d %s\r\n"), code, websErrorMsg(code));
+/*
+ * Redirect behaves much better when sent with HTTP/1.0
+ */
+ if (redirect != NULL) {
+ websWrite(wp, T("HTTP/1.0 %d %s\r\n"), code, websErrorMsg(code));
+ } else {
+ websWrite(wp, T("HTTP/1.1 %d %s\r\n"), code, websErrorMsg(code));
+ }
+
/*
* By license terms the following line of code must not be modified.
*/
@@ -1280,8 +1342,13 @@ void websResponse(webs_t wp, int code, char_t *message, char_t *redirect)
} else {
char_t *nonce, *opaque;
+ /* $$$ before... (note commas instead of semicolons...)
nonce = websCalcNonce(wp),
opaque = websCalcOpaque(wp),
+ $$$ after */
+ nonce = websCalcNonce(wp);
+ opaque = websCalcOpaque(wp);
+ /* ...$$$ end */
websWrite(wp,
T("WWW-Authenticate: Digest realm=\"%s\", domain=\"%s\",")
T("qop=\"%s\", nonce=\"%s\", opaque=\"%s\",")
@@ -1381,10 +1448,17 @@ void websRedirect(webs_t wp, char_t *url)
* Output an error message and cleanup
*/
+#ifdef qRichErrorPage
+extern int dmfRichError(webs_t wp, int code, char_t* userMsg);
+#endif
void websError(webs_t wp, int code, char_t *fmt, ...)
{
va_list args;
char_t *msg, *userMsg, *buf;
+#ifdef qRichErrorPage
+ static int reEntry = 0;
+ int errorOk;
+#endif
a_assert(websValid(wp));
a_assert(fmt);
@@ -1396,6 +1470,30 @@ void websError(webs_t wp, int code, char_t *fmt, ...)
fmtValloc(&userMsg, WEBS_BUFSIZE, fmt, args);
va_end(args);
+#ifdef qRichErrorPage
+ if (!reEntry)
+ {
+ /*
+ * The dmfRichError function that we're about to call may very well call
+ * websError() as part of its work. If that happens, we do NOT want to
+ * get into a never-ending recursive call chain. When we get back here
+ * in a call from inside dmfRichError(), we check to see if we're
+ * already trying to call dmfRichError. If we are, we just revert to the
+ * old non-rich behavior and display a black on white error page.
+ */
+
+ reEntry = 1;
+ errorOk = dmfRichError(wp, code, userMsg);
+ reEntry = 0;
+ if (errorOk)
+ {
+ return;
+ }
+ /* ...else we need to fall through and execute the simple error page. */
+ }
+ /* implicit else... */
+#endif
+
msg = T("<html><head><title>Document Error: %s</title></head>\r\n\
<body><h2>Access Error: %s</h2>\r\n\
when trying to obtain <b>%s</b><br><p>%s</p></body></html>\r\n");
@@ -1416,7 +1514,8 @@ void websError(webs_t wp, int code, char_t *fmt, ...)
* Return the error message for a given code
*/
-static char_t *websErrorMsg(int code)
+/*static char_t *websErrorMsg(int code)*/
+char_t *websErrorMsg(int code)
{
websErrorType *ep;
@@ -1447,9 +1546,11 @@ int websWrite(webs_t wp, char_t *fmt, ...)
buf = NULL;
rc = 0;
+
if (fmtValloc(&buf, WEBS_BUFSIZE, fmt, vargs) >= WEBS_BUFSIZE) {
trace(0, T("webs: websWrite lost data, buffer overflow\n"));
}
+
va_end(vargs);
a_assert(buf);
if (buf) {
@@ -1597,7 +1698,7 @@ void websDecodeUrl(char_t *decoded, char_t *token, int len)
}
/******************************************************************************/
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
/*
* Output a log message
*/
@@ -1607,12 +1708,30 @@ static void websLog(webs_t wp, int code)
char_t *buf;
char *abuf;
int len;
-
+#define qAnlLog 1
+#ifdef qAnlLog
+ time_t timer;
+ char_t* newLine = NULL;
+ char_t* timeStr = NULL;
+#endif
a_assert(websValid(wp));
buf = NULL;
+
+#ifdef qAnlLog
+ time(&timer);
+ timeStr = ctime(&timer);
+ newLine = gstrchr(timeStr, '\n');
+ if (newLine)
+ {
+ *newLine = '\0';
+ }
+ fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%s\t%s\t%s\tcode = %d\n"),
+ timeStr, wp->ipaddr, wp->url, code);
+#else
fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%d %s %d %d\n"), time(0),
wp->url, code, wp->written);
+#endif
len = gstrlen(buf);
abuf = ballocUniToAsc(buf, len+1);
write(websLogFd, abuf, len);
@@ -1647,7 +1766,6 @@ void websTimeout(void *arg, int id)
*/
wp->timeout = -1;
websDone(wp, 404);
-
} else {
delay = WEBS_TIMEOUT - tm;
a_assert(delay > 0);
@@ -1673,13 +1791,13 @@ void websDone(webs_t wp, int code)
wp->flags &= ~WEBS_KEEP_ALIVE;
}
-#if WEBS_PROXY_SUPPORT
+#ifdef WEBS_PROXY_SUPPORT
if (! (wp->flags & WEBS_LOCAL_PAGE)) {
websStats.activeNetRequests--;
}
#endif
-#if WEBS_LOG_SUPPORT
+#ifdef WEBS_LOG_SUPPORT
if (! (wp->flags & WEBS_REQUEST_DONE)) {
websLog(wp, code);
}
@@ -1960,7 +2078,7 @@ char_t *websGetRequestLpath(webs_t wp)
{
a_assert(websValid(wp));
-#if WEBS_PAGE_ROM
+#ifdef WEBS_PAGE_ROM
return wp->path;
#else
return wp->lpath;
@@ -2209,7 +2327,7 @@ char_t *websGetDateString(websStatType *sbuf)
* "real" time, but rather a relative marker.
*/
-void websMarkTime(webs_t wp)
+void websSetTimeMark(webs_t wp)
{
wp->timestamp = time(0);
}
@@ -2247,7 +2365,7 @@ char_t *websGetRealm()
}
-#if WEBS_IF_MODIFIED_SUPPORT
+#ifdef WEBS_IF_MODIFIED_SUPPORT
/******************************************************************************/
/*
* These functions are intended to closely mirror the syntax for HTTP-date
@@ -2582,7 +2700,13 @@ static time_t dateToTimet(int year, int month, int day)
{
long dayDifference;
- dayDifference = FixedFromGregorian(month, day, year) -
+ /*
+ * Bug fix by Jeff Reeder (Jun 14, 2002): The 'month' parameter is
+ * numbered from 0 (Jan == 0), but FixedFromGregorian() takes
+ * months numbered from 1 (January == 1). We need to add 1
+ * to the month
+ */
+ dayDifference = FixedFromGregorian(month + 1, day, year) -
FixedFromGregorian(1, 1, 1970);
return dayDifference * SECONDS_PER_DAY;
@@ -2834,5 +2958,4 @@ static time_t dateParse(time_t tip, char_t *cmd)
#endif /* WEBS_IF_MODIFIED_SUPPORT */
-
/******************************************************************************/
diff --git a/c/src/libnetworking/rtems_webserver/webs.h b/c/src/libnetworking/rtems_webserver/webs.h
index 4b847502a5..9bc61ddf5e 100644
--- a/c/src/libnetworking/rtems_webserver/webs.h
+++ b/c/src/libnetworking/rtems_webserver/webs.h
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
*
* See the file "license.txt" for information on usage and redistribution
+ *
+ * $Id$
*/
#ifndef _h_WEBS
@@ -21,7 +23,7 @@
#include "ej.h"
#ifdef WEBS_SSL_SUPPORT
-#include "websSSL.h"
+ #include "websSSL.h"
#endif
/********************************** Defines ***********************************/
@@ -30,7 +32,7 @@
* code must not be modified.
*/
#define WEBS_NAME T("GoAhead-Webs")
-#define WEBS_VERSION T("2.1")
+#define WEBS_VERSION T("2.1.3")
#define WEBS_HEADER_BUFINC 512 /* Header buffer size */
#define WEBS_ASP_BUFINC 512 /* Asp expansion increment */
@@ -140,6 +142,8 @@ extern void websDecodeUrl(char_t *token, char_t *decoded, int len);
extern void websDone(webs_t wp, int code);
extern void websEncode64(char_t *outbuf, char_t *string, int buflen);
extern void websError(webs_t wp, int code, char_t *msg, ...);
+/* function websErrorMsg() made extern 03 Jun 02 BgP */
+extern char_t *websErrorMsg(int code);
extern void websFooter(webs_t wp);
extern int websFormDefine(char_t *name, void (*fn)(webs_t wp,
char_t *path, char_t *query));
@@ -206,7 +210,7 @@ extern int websWriteBlock(webs_t wp, char_t *buf, int nChars);
extern int websWriteDataNonBlock(webs_t wp, char *buf, int nChars);
extern int websValid(webs_t wp);
extern int websValidateUrl(webs_t wp, char_t *path);
-extern void websMarkTime(webs_t wp);
+extern void websSetTimeMark(webs_t wp);
/*
* The following prototypes are used by the SSL patch found in websSSL.c
@@ -220,7 +224,7 @@ extern void websReadEvent(webs_t wp);
* Prototypes for functions available when running as part of the
* GoAhead Embedded Management Framework (EMF)
*/
-#if EMF
+#ifdef EMF
extern void websFormExplain(webs_t wp, char_t *path, char_t *query);
#endif
diff --git a/c/src/libnetworking/rtems_webserver/websuemf.c b/c/src/libnetworking/rtems_webserver/websuemf.c
index 2315d9d234..a59bca1a18 100644
--- a/c/src/libnetworking/rtems_webserver/websuemf.c
+++ b/c/src/libnetworking/rtems_webserver/websuemf.c
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
*
* See the file "license.txt" for usage and redistribution license requirements
+ *
+ * $Id$
*/
/********************************** Description *******************************/
@@ -45,7 +47,12 @@ int scriptEval(int engine, char_t *cmd, char_t **result, int chan)
if (engine == EMF_SCRIPT_EJSCRIPT) {
ejid = (int) chan;
- if (ejEval(ejid, cmd, NULL) ) {
+ /*
+ * NOTE -- to disable better reporting of ASP errors, change the
+ * following line of code to
+ * if (ejEval(ejid, cmd, NULL) ) {
+ */
+ if (ejEval(ejid, cmd, result) ) {
return 0;
} else {
return -1;
diff --git a/c/src/libnetworking/rtems_webserver/wsIntrn.h b/c/src/libnetworking/rtems_webserver/wsIntrn.h
index 8f230d6fbe..9fb11f9937 100644
--- a/c/src/libnetworking/rtems_webserver/wsIntrn.h
+++ b/c/src/libnetworking/rtems_webserver/wsIntrn.h
@@ -4,6 +4,8 @@
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
*
* See the file "license.txt" for information on usage and redistribution
+ *
+ * $Id$
*/
#ifndef _h_WEBS_INTERNAL
@@ -19,7 +21,7 @@
/*********************************** Defines **********************************/
/*
- * Define this to enable login of web accesses to a file
+ * Define this to enable logging of web accesses to a file
* #define WEBS_LOG_SUPPORT 1
*
* Define this to enable HTTP/1.1 keep alive support
@@ -46,45 +48,52 @@
#include <string.h>
#include <stdarg.h>
-#if WIN
+#ifdef NETWARE
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <signal.h>
+ #include <io.h>
+#endif
+
+#ifdef WIN
#include <fcntl.h>
#include <sys/stat.h>
#include <io.h>
#endif
-#if CE
-#if ! UEMF
+#ifdef CE
+#ifndef UEMF
#include <io.h>
#endif
#endif
-#if NW
+#ifdef NW
#include <fcntl.h>
#include <sys/stat.h>
#endif
-#if SCOV5
+#ifdef SCOV5
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
#include <unistd.h>
#endif
-#if LYNX
+#ifdef LYNX
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
#include <unistd.h>
#endif
-#if UNIX
+#ifdef UNIX
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
#include <unistd.h>
#endif
-#if QNX4
+#ifdef QNX4
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
@@ -92,24 +101,24 @@
#include <unix.h>
#endif
-#if UW
+#ifdef UW
#include <fcntl.h>
#include <sys/stat.h>
#endif
-#if VXWORKS
+#ifdef VXWORKS
#include <vxWorks.h>
#include <fcntl.h>
#include <sys/stat.h>
#endif
-#if SOLARIS
+#ifdef SOLARIS
#include <macros.h>
#include <fcntl.h>
#include <sys/stat.h>
#endif
-#if UEMF
+#ifdef UEMF
#include "uemf.h"
#include "ejIntrn.h"
#else
@@ -134,7 +143,6 @@
#define PAGE_READ_BUFSIZE 512 /* bytes read from page files */
#define MAX_PORT_LEN 10 /* max digits in port number */
#define WEBS_SYM_INIT 64 /* initial # of sym table entries */
-#define WEBS_VERSION_STR T("2.1.3") /* version of web server s/w */
/*
* URL handler structure. Stores the leading URL path and the handler
@@ -201,7 +209,7 @@ typedef struct {
*/
typedef struct {
char_t *path; /* Web page URL path */
- const unsigned char *page; /* Web page data */
+ unsigned char *page; /* Web page data */
int size; /* Size of web page in bytes */
int pos; /* Current read position */
} websRomPageIndexType;
@@ -285,13 +293,13 @@ extern int strcmpci(char_t* s1, char_t* s2);
* Prototypes for functions available when running as part of the
* GoAhead Embedded Management Framework (EMF)
*/
-#if EMF
+#ifdef EMF
extern int websEmfOpen();
extern void websEmfClose();
extern void websSetEmfEnvironment(webs_t wp);
#endif
-#if CE
+#ifdef CE
extern int writeUniToAsc(int fid, void *buf, unsigned int len);
extern int readAscToUni(int fid, void **buf, unsigned int len);
#endif