added space for port number (when not 80) in xmlNanoHTTPMethodRedir, plus
* nanohttp.c: added space for port number (when not 80) in
xmlNanoHTTPMethodRedir, plus a few more comments. Should
fix #514521.
svn path=/trunk/; revision=3685
diff --git a/nanohttp.c b/nanohttp.c
index 91c7e87..07829c7 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -1332,13 +1332,23 @@
if (headers != NULL)
blen += strlen(headers) + 2;
if (contentType && *contentType)
+ /* reserve for string plus 'Content-Type: \r\n" */
blen += strlen(*contentType) + 16;
if (ctxt->query != NULL)
+ /* 1 for '?' */
blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24;
#ifdef HAVE_ZLIB_H
+ /* reserve for possible 'Accept-Encoding: gzip' string */
blen += 23;
#endif
+ if (ctxt->port != 80) {
+ /* reserve space for ':xxxxx', incl. potential proxy */
+ if (proxy)
+ blen += 12;
+ else
+ blen += 6;
+ }
bp = (char*)xmlMallocAtomic(blen);
if ( bp == NULL ) {
xmlNanoHTTPFreeCtxt( ctxt );