mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Check for 'Content-Length:' case-insensitive
This commit is contained in:
parent
f22f35fe21
commit
318b1cb1a2
@ -28768,8 +28768,8 @@ int process_http_request(const char *crequest, int i_conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* extract content length */
|
/* extract content length */
|
||||||
if (strstr(crequest, "Content-Length:")) {
|
if (strcasestr(crequest, "Content-Length:")) {
|
||||||
content_length = atoi(strstr(crequest, "Content-Length:") + 15);
|
content_length = atoi(strcasestr(crequest, "Content-Length:") + 15);
|
||||||
|
|
||||||
strsize = content_length + header_length + 15;
|
strsize = content_length + header_length + 15;
|
||||||
}
|
}
|
||||||
@ -28944,7 +28944,7 @@ int process_http_request(const char *crequest, int i_conn) {
|
|||||||
keep_alive = TRUE;
|
keep_alive = TRUE;
|
||||||
|
|
||||||
/* extract logbook */
|
/* extract logbook */
|
||||||
if (strchr(request, '/') == NULL || strchr(request, '\r') == NULL || strstr(request, "HTTP") == NULL) {
|
if (strchr(request, '/') == NULL || strchr(request, '\r') == NULL || strcasestr(request, "HTTP") == NULL) {
|
||||||
/* invalid request, make valid */
|
/* invalid request, make valid */
|
||||||
strcpy(str, "GET / HTTP/1.0\r\n\r\n");
|
strcpy(str, "GET / HTTP/1.0\r\n\r\n");
|
||||||
xfree(str);
|
xfree(str);
|
||||||
@ -29265,12 +29265,12 @@ int process_http_request(const char *crequest, int i_conn) {
|
|||||||
/* extract path and commands */
|
/* extract path and commands */
|
||||||
if (strchr(request, '\r'))
|
if (strchr(request, '\r'))
|
||||||
*strchr(request, '\r') = 0;
|
*strchr(request, '\r') = 0;
|
||||||
if (!strstr(request, "HTTP/1")) {
|
if (!strcasestr(request, "HTTP/1")) {
|
||||||
xfree(str);
|
xfree(str);
|
||||||
xfree(request);
|
xfree(request);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*(strstr(request, "HTTP/1") - 1) = 0;
|
*(strcasestr(request, "HTTP/1") - 1) = 0;
|
||||||
/* strip logbook from path */
|
/* strip logbook from path */
|
||||||
strlcpy(str, request + 5, strsize);
|
strlcpy(str, request + 5, strsize);
|
||||||
p = str;
|
p = str;
|
||||||
@ -29284,10 +29284,10 @@ int process_http_request(const char *crequest, int i_conn) {
|
|||||||
} else if (strncmp(request, "POST", 4) == 0) {
|
} else if (strncmp(request, "POST", 4) == 0) {
|
||||||
|
|
||||||
/* extract content length */
|
/* extract content length */
|
||||||
if (strstr(request, "Content-Length:"))
|
if (strcasestr(request, "Content-Length:"))
|
||||||
content_length = atoi(strstr(request, "Content-Length:") + 15);
|
content_length = atoi(strcasestr(request, "Content-Length:") + 15);
|
||||||
else if (strstr(request, "Content-length:"))
|
else if (strcasestr(request, "Content-length:"))
|
||||||
content_length = atoi(strstr(request, "Content-length:") + 15);
|
content_length = atoi(strcasestr(request, "Content-length:") + 15);
|
||||||
if (content_length <= 0) {
|
if (content_length <= 0) {
|
||||||
show_error("Invalid Content-Length in header");
|
show_error("Invalid Content-Length in header");
|
||||||
xfree(str);
|
xfree(str);
|
||||||
@ -29296,8 +29296,8 @@ int process_http_request(const char *crequest, int i_conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* extract boundary */
|
/* extract boundary */
|
||||||
if (strstr(request, "boundary=")) {
|
if (strcasestr(request, "boundary=")) {
|
||||||
strlcpy(boundary, strstr(request, "boundary=") + 9, sizeof(boundary));
|
strlcpy(boundary, strcasestr(request, "boundary=") + 9, sizeof(boundary));
|
||||||
if (strchr(boundary, '\r'))
|
if (strchr(boundary, '\r'))
|
||||||
*strchr(boundary, '\r') = 0;
|
*strchr(boundary, '\r') = 0;
|
||||||
}
|
}
|
||||||
@ -29355,10 +29355,8 @@ void send_return(int s, const char *net_buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
length = 0;
|
length = 0;
|
||||||
if ((keep_alive && strstr(return_buffer, "Content-Length") == NULL) || strstr(return_buffer,
|
if ((keep_alive && strcasestr(return_buffer, "Content-Length") == NULL) ||
|
||||||
"Content-Length") >
|
strcasestr(return_buffer, "Content-Length") > strstr(return_buffer, "\r\n\r\n")) {
|
||||||
strstr(return_buffer,
|
|
||||||
"\r\n\r\n")) {
|
|
||||||
|
|
||||||
/*---- add content-length ----*/
|
/*---- add content-length ----*/
|
||||||
|
|
||||||
@ -29884,27 +29882,27 @@ void server_loop(void) {
|
|||||||
strlcpy(_identify_cmd, "identify", sizeof(_convert_cmd));
|
strlcpy(_identify_cmd, "identify", sizeof(_convert_cmd));
|
||||||
sprintf(str, "%s -version", _convert_cmd);
|
sprintf(str, "%s -version", _convert_cmd);
|
||||||
my_shell(str, str, sizeof(str));
|
my_shell(str, str, sizeof(str));
|
||||||
image_magick_exist = (strstr(str, "ImageMagick") != NULL);
|
image_magick_exist = (strcasestr(str, "ImageMagick") != NULL);
|
||||||
if (!image_magick_exist) {
|
if (!image_magick_exist) {
|
||||||
strlcpy(_convert_cmd, "/usr/bin/convert", sizeof(_convert_cmd));
|
strlcpy(_convert_cmd, "/usr/bin/convert", sizeof(_convert_cmd));
|
||||||
strlcpy(_identify_cmd, "/usr/bin/identify", sizeof(_convert_cmd));
|
strlcpy(_identify_cmd, "/usr/bin/identify", sizeof(_convert_cmd));
|
||||||
sprintf(str, "%s -version", _convert_cmd);
|
sprintf(str, "%s -version", _convert_cmd);
|
||||||
my_shell(str, str, sizeof(str));
|
my_shell(str, str, sizeof(str));
|
||||||
image_magick_exist = (strstr(str, "ImageMagick") != NULL);
|
image_magick_exist = (strcasestr(str, "ImageMagick") != NULL);
|
||||||
}
|
}
|
||||||
if (!image_magick_exist) {
|
if (!image_magick_exist) {
|
||||||
strlcpy(_convert_cmd, "/usr/local/bin/convert", sizeof(_convert_cmd));
|
strlcpy(_convert_cmd, "/usr/local/bin/convert", sizeof(_convert_cmd));
|
||||||
strlcpy(_identify_cmd, "/usr/local/bin/identify", sizeof(_convert_cmd));
|
strlcpy(_identify_cmd, "/usr/local/bin/identify", sizeof(_convert_cmd));
|
||||||
sprintf(str, "%s -version", _convert_cmd);
|
sprintf(str, "%s -version", _convert_cmd);
|
||||||
my_shell(str, str, sizeof(str));
|
my_shell(str, str, sizeof(str));
|
||||||
image_magick_exist = (strstr(str, "ImageMagick") != NULL);
|
image_magick_exist = (strcasestr(str, "ImageMagick") != NULL);
|
||||||
}
|
}
|
||||||
if (!image_magick_exist) {
|
if (!image_magick_exist) {
|
||||||
strlcpy(_convert_cmd, "/opt/local/bin/convert", sizeof(_convert_cmd));
|
strlcpy(_convert_cmd, "/opt/local/bin/convert", sizeof(_convert_cmd));
|
||||||
strlcpy(_identify_cmd, "/opt/local/bin/identify", sizeof(_convert_cmd));
|
strlcpy(_identify_cmd, "/opt/local/bin/identify", sizeof(_convert_cmd));
|
||||||
sprintf(str, "%s -version", _convert_cmd);
|
sprintf(str, "%s -version", _convert_cmd);
|
||||||
my_shell(str, str, sizeof(str));
|
my_shell(str, str, sizeof(str));
|
||||||
image_magick_exist = (strstr(str, "ImageMagick") != NULL);
|
image_magick_exist = (strcasestr(str, "ImageMagick") != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_magick_exist)
|
if (image_magick_exist)
|
||||||
@ -30185,17 +30183,17 @@ void server_loop(void) {
|
|||||||
if (header_length == 0) {
|
if (header_length == 0) {
|
||||||
/* extract logbook */
|
/* extract logbook */
|
||||||
strlcpy(str, net_buffer + 6, sizeof(str));
|
strlcpy(str, net_buffer + 6, sizeof(str));
|
||||||
if (strstr(str, "HTTP"))
|
if (strcasestr(str, "HTTP"))
|
||||||
*(strstr(str, "HTTP") - 1) = 0;
|
*(strcasestr(str, "HTTP") - 1) = 0;
|
||||||
strlcpy(logbook, str, sizeof(logbook));
|
strlcpy(logbook, str, sizeof(logbook));
|
||||||
strlcpy(logbook_enc, str, sizeof(logbook));
|
strlcpy(logbook_enc, str, sizeof(logbook));
|
||||||
url_decode(logbook);
|
url_decode(logbook);
|
||||||
|
|
||||||
/* extract content length */
|
/* extract content length */
|
||||||
if (strstr(net_buffer, "Content-Length:"))
|
if (strcasestr(net_buffer, "Content-Length:"))
|
||||||
content_length = atoi(strstr(net_buffer, "Content-Length:") + 15);
|
content_length = atoi(strcasestr(net_buffer, "Content-Length:") + 15);
|
||||||
else if (strstr(net_buffer, "Content-length:"))
|
else if (strcasestr(net_buffer, "Content-length:"))
|
||||||
content_length = atoi(strstr(net_buffer, "Content-length:") + 15);
|
content_length = atoi(strcasestr(net_buffer, "Content-length:") + 15);
|
||||||
|
|
||||||
/* check for valid content-length */
|
/* check for valid content-length */
|
||||||
if (content_length < 0) {
|
if (content_length < 0) {
|
||||||
@ -30257,7 +30255,7 @@ void server_loop(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (strstr(net_buffer, "HEAD") != NULL) {
|
} else if (strcasestr(net_buffer, "HEAD") != NULL) {
|
||||||
/* just return header */
|
/* just return header */
|
||||||
rsprintf("HTTP/1.1 200 OK\r\n");
|
rsprintf("HTTP/1.1 200 OK\r\n");
|
||||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||||
@ -30266,7 +30264,7 @@ void server_loop(void) {
|
|||||||
keep_alive = FALSE;
|
keep_alive = FALSE;
|
||||||
return_length = strlen_retbuf + 1;
|
return_length = strlen_retbuf + 1;
|
||||||
break;
|
break;
|
||||||
} else if (strstr(net_buffer, "OPTIONS") != NULL) {
|
} else if (strcasestr(net_buffer, "OPTIONS") != NULL) {
|
||||||
return_length = -1;
|
return_length = -1;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user