From c5a26208302f65c9cb54d4541fe1004799d72f80 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Fri, 10 May 2019 01:14:21 -0700 Subject: added latest cgic --- cgic.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cgic.c b/cgic.c index 4cb7521..4eef9ed 100644 --- a/cgic.c +++ b/cgic.c @@ -4,9 +4,10 @@ /* Used only in Unix environments, in conjunction with mkstemp(). Elsewhere (Windows), temporary files go where the tmpnam() function suggests. If this behavior does not work for you, - modify the getTempFileName() function to suit your needs. */ + modify the getTempFile() function to suit your needs. */ #define cgicTempDir "/tmp" +#define cgicMaxTempSize 1073741824 #if CGICDEBUG #define CGICDEBUGSTART \ @@ -436,7 +437,7 @@ static void decomposeValue(char *value, char **argValues, int argValueSpace); -static cgiParseResultType getTempFileName(FILE **tFile); +static cgiParseResultType getTempFile(FILE **tFile); static cgiParseResultType cgiParsePostMultipartInput() { cgiParseResultType result; @@ -528,7 +529,7 @@ static cgiParseResultType cgiParsePostMultipartInput() { Otherwise, store to a memory buffer (it is presumably a regular form field). */ if (strlen(ffileName)) { - if (getTempFileName(&outf) != cgiParseSuccess) { + if (getTempFile(&outf) != cgiParseSuccess) { return cgiParseIO; } } else { @@ -624,7 +625,7 @@ outOfMemory: return cgiParseMemory; } -static cgiParseResultType getTempFileName(FILE **tFile) +static cgiParseResultType getTempFile(FILE **tFile) { /* tfileName must be 1024 bytes to ensure adequacy on win32 (1024 exceeds the maximum path length and @@ -758,12 +759,10 @@ cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char **outP, /* Not presently in the middle of a boundary match; just emit the character. */ BAPPEND(d[0]); - } -#ifdef CGIMAXTEMPFILESIZE - if(outLen >= CGIMAXTEMPFILESIZE) { + } + if(outLen > cgicMaxTempSize) { goto outOfMemory; } -#endif } /* Read trailing newline or -- EOF marker. A literal EOF here would be an error in the input stream. */ @@ -2165,7 +2164,7 @@ cgiEnvironmentResultType cgiReadEnvironment(char *filename) { FILE *out = NULL; int got; int len = e->valueLength; - if (getTempFileName(&out) + if (getTempFile(&out) != cgiParseSuccess || !out) { result = cgiEnvironmentIO; -- cgit v1.2.3