Fossil SCM
Check-in [acffc8f7858254eb] was causing "CGI content-length mismatch" errors on the main Fossil website (xinet.d->althttpd->Fossil). This check-in attempts to resolve the problem.
Commit
c5c7dd5ffbf424bd84a5973649c3cef071f0631a2d1151a311a8e834f6cf5585
Parent
42c4d045e10f40b…
1 file changed
+10
-13
+10
-13
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -1316,28 +1316,25 @@ | ||
| 1316 | 1316 | }else{ |
| 1317 | 1317 | g.zContentType = zType; |
| 1318 | 1318 | } |
| 1319 | 1319 | blob_zero(&g.cgiIn); |
| 1320 | 1320 | if( len>0 && zType ){ |
| 1321 | + if( blob_read_from_cgi(&g.cgiIn, len)<len ){ | |
| 1322 | + char *zMsg = mprintf("CGI content-length mismatch: Wanted %d bytes" | |
| 1323 | + " but got only %d\n", len, blob_size(&g.cgiIn)); | |
| 1324 | + malformed_request(zMsg); | |
| 1325 | + } | |
| 1321 | 1326 | if( fossil_strcmp(zType, "application/x-fossil")==0 ){ |
| 1322 | - if( blob_read_from_cgi(&g.cgiIn, len)!=len ){ | |
| 1323 | - malformed_request("CGI content-length mismatch"); | |
| 1324 | - } | |
| 1325 | 1327 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 1326 | 1328 | } |
| 1327 | - else{ | |
| 1328 | - if( blob_read_from_cgi(&g.cgiIn, len)!=len ){ | |
| 1329 | - malformed_request("CGI content-length mismatch"); | |
| 1330 | - } | |
| 1331 | 1329 | #ifdef FOSSIL_ENABLE_JSON |
| 1332 | - if( noJson==0 && g.json.isJsonMode!=0 | |
| 1333 | - && json_can_consume_content_type(zType)!=0 ){ | |
| 1334 | - cgi_parse_POST_JSON(&g.cgiIn); | |
| 1335 | - cgi_set_content_type(json_guess_content_type()); | |
| 1336 | - } | |
| 1337 | -#endif /* FOSSIL_ENABLE_JSON */ | |
| 1330 | + if( noJson==0 && g.json.isJsonMode!=0 | |
| 1331 | + && json_can_consume_content_type(zType)!=0 ){ | |
| 1332 | + cgi_parse_POST_JSON(&g.cgiIn); | |
| 1333 | + cgi_set_content_type(json_guess_content_type()); | |
| 1338 | 1334 | } |
| 1335 | +#endif /* FOSSIL_ENABLE_JSON */ | |
| 1339 | 1336 | } |
| 1340 | 1337 | } |
| 1341 | 1338 | |
| 1342 | 1339 | /* |
| 1343 | 1340 | ** Decode POST parameter information in the cgiIn content, if any. |
| 1344 | 1341 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1316,28 +1316,25 @@ | |
| 1316 | }else{ |
| 1317 | g.zContentType = zType; |
| 1318 | } |
| 1319 | blob_zero(&g.cgiIn); |
| 1320 | if( len>0 && zType ){ |
| 1321 | if( fossil_strcmp(zType, "application/x-fossil")==0 ){ |
| 1322 | if( blob_read_from_cgi(&g.cgiIn, len)!=len ){ |
| 1323 | malformed_request("CGI content-length mismatch"); |
| 1324 | } |
| 1325 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 1326 | } |
| 1327 | else{ |
| 1328 | if( blob_read_from_cgi(&g.cgiIn, len)!=len ){ |
| 1329 | malformed_request("CGI content-length mismatch"); |
| 1330 | } |
| 1331 | #ifdef FOSSIL_ENABLE_JSON |
| 1332 | if( noJson==0 && g.json.isJsonMode!=0 |
| 1333 | && json_can_consume_content_type(zType)!=0 ){ |
| 1334 | cgi_parse_POST_JSON(&g.cgiIn); |
| 1335 | cgi_set_content_type(json_guess_content_type()); |
| 1336 | } |
| 1337 | #endif /* FOSSIL_ENABLE_JSON */ |
| 1338 | } |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | /* |
| 1343 | ** Decode POST parameter information in the cgiIn content, if any. |
| 1344 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1316,28 +1316,25 @@ | |
| 1316 | }else{ |
| 1317 | g.zContentType = zType; |
| 1318 | } |
| 1319 | blob_zero(&g.cgiIn); |
| 1320 | if( len>0 && zType ){ |
| 1321 | if( blob_read_from_cgi(&g.cgiIn, len)<len ){ |
| 1322 | char *zMsg = mprintf("CGI content-length mismatch: Wanted %d bytes" |
| 1323 | " but got only %d\n", len, blob_size(&g.cgiIn)); |
| 1324 | malformed_request(zMsg); |
| 1325 | } |
| 1326 | if( fossil_strcmp(zType, "application/x-fossil")==0 ){ |
| 1327 | blob_uncompress(&g.cgiIn, &g.cgiIn); |
| 1328 | } |
| 1329 | #ifdef FOSSIL_ENABLE_JSON |
| 1330 | if( noJson==0 && g.json.isJsonMode!=0 |
| 1331 | && json_can_consume_content_type(zType)!=0 ){ |
| 1332 | cgi_parse_POST_JSON(&g.cgiIn); |
| 1333 | cgi_set_content_type(json_guess_content_type()); |
| 1334 | } |
| 1335 | #endif /* FOSSIL_ENABLE_JSON */ |
| 1336 | } |
| 1337 | } |
| 1338 | |
| 1339 | /* |
| 1340 | ** Decode POST parameter information in the cgiIn content, if any. |
| 1341 |