$NetBSD$ --- nanohttp.c.orig 2000-06-28 18:33:46.000000000 +0000 +++ nanohttp.c @@ -161,6 +161,7 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ct const char *cur = URL; char buf[4096]; int index = 0; + const int indexMax = 4096 - 1; int port = 0; if (ctxt->protocol != NULL) { @@ -177,7 +178,7 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ct } if (URL == NULL) return; buf[index] = 0; - while (*cur != 0) { + while ((*cur != 0) && (index < indexMax)) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { buf[index] = 0; ctxt->protocol = xmlMemStrdup(buf); @@ -219,7 +220,7 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ct else { index = 0; buf[index] = 0; - while (*cur != 0) + while ((*cur != 0) && (index < indexMax)) buf[index++] = *cur++; buf[index] = 0; ctxt->path = xmlMemStrdup(buf); @@ -241,6 +242,7 @@ xmlNanoHTTPScanProxy(const char *URL) { const char *cur = URL; char buf[4096]; int index = 0; + const int indexMax = 4096 - 1; int port = 0; if (proxy != NULL) { @@ -258,7 +260,7 @@ xmlNanoHTTPScanProxy(const char *URL) { #endif if (URL == NULL) return; buf[index] = 0; - while (*cur != 0) { + while ((*cur != 0) && (index < indexMax)) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { buf[index] = 0; index = 0; @@ -1182,7 +1184,7 @@ xmlNanoHTTPSave(void *ctxt, const char * if (!strcmp(filename, "-")) fd = 0; else { - fd = open(filename, O_CREAT | O_WRONLY); + fd = open(filename, O_CREAT | O_WRONLY, 00644); if (fd < 0) { xmlNanoHTTPClose(ctxt); return(-1);