[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/06: parse_http_version(): cosmetics
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/06: parse_http_version(): cosmetics |
Date: |
Mon, 19 Dec 2022 16:18:00 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit c47bb426b67e9d4289d0344db8d04bac07998562
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Nov 16 16:15:00 2022 +0300
parse_http_version(): cosmetics
---
src/microhttpd/connection.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 19d1c699..960c22db 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3183,8 +3183,14 @@ parse_cookie_header (struct MHD_Connection *connection)
#endif /* COOKIE_SUPPORT */
+
+/**
+ * The valid length of any HTTP version string
+ */
+#define HTTP_VER_LEN (MHD_STATICSTR_LEN_(MHD_HTTP_VERSION_1_1))
+
/**
- * Detect HTTP version
+ * Detect HTTP version, send error response if version is not supported
*
* @param connection the connection
* @param http_string the pointer to HTTP version string
@@ -3201,13 +3207,13 @@ parse_http_version (struct MHD_Connection *connection,
mhd_assert (NULL != http_string);
/* String must start with 'HTTP/d.d', case-sensetive match.
- * See https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 */
- if ((len != 8) ||
- (h[0] != 'H') || (h[1] != 'T') || (h[2] != 'T') || (h[3] != 'P') ||
- (h[4] != '/')
- || (h[6] != '.') ||
- ((h[5] < '0') || (h[5] > '9')) ||
- ((h[7] < '0') || (h[7] > '9')))
+ * See https://www.rfc-editor.org/rfc/rfc9112#name-http-version */
+ if ((HTTP_VER_LEN != len) ||
+ ('H' != h[0] ) || ('T' != h[1]) || ('T' != h[2]) || ('P' != h[3]) ||
+ ('/' != h[4])
+ || ('.' != h[6]) ||
+ (('0' > h[5]) || ('9' < h[5])) ||
+ (('0' > h[7]) || ('9' < h[7])))
{
connection->rq.http_ver = MHD_HTTP_VER_INVALID;
transmit_error_response_static (connection,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (3444792f -> 1e7ad301), gnunet, 2022/12/19
- [libmicrohttpd] 01/06: response.c: added new internal function to avoid repetitive malloc()s, gnunet, 2022/12/19
- [libmicrohttpd] 03/06: parse_http_version(): cosmetics,
gnunet <=
- [libmicrohttpd] 05/06: test_parse_cookies: rewritten, gnunet, 2022/12/19
- [libmicrohttpd] 06/06: Refactored cookies parsing., gnunet, 2022/12/19
- [libmicrohttpd] 04/06: MHD_get_version_bin(): added new function, gnunet, 2022/12/19
- [libmicrohttpd] 02/06: digestauth: avoid malloc() repeat by using the new function, gnunet, 2022/12/19