error: sometimes cgi could not parse form fields of http post request when length of boundary changes
Some browsers change length of boundary string in multipart http post requests (for example Firefox). So, cgi_parse() -> parse_rfc2388() functions could not correctly parse some requests because of error, that is located in _find_boundary() function (cgi/rfc2388.c).
Simple (but not best) solution is to remove "pointless optimization of strlen(boundary)" from _find_boundary() function. Reason of the error is that if system has no memory leaks and processes small number of requests, there is probability, that two "boundary" strings (with different length) will be allocated at the same address...
---BAD-------- static BOOL _is_boundary (char *boundary, char *s, int l, int *done) { static char *old_boundary = NULL; static int bl;
/* cache the boundary strlen... more pointless optimization by blong */ if (old_boundary != boundary) { old_boundary = boundary; bl = strlen(boundary); }
if (s[l-1] != '\n') return FALSE; l--;
---GOOD----- static BOOL _is_boundary (char *boundary, char *s, int l, int *done) { int bl = strlen(boundary);
if (s[l-1] != '\n') return FALSE; l--;
Other way (most effective) is to add some mechanism to refresh "bl" without described error.
Thanks!