Skip to content

Commit

Permalink
Current version of Psi+ is 1.5.1700
Browse files Browse the repository at this point in the history
It is based on:
* psi: 33c6541f
* plugins: 3134d80
* psimedia: 9fd3307
* resources: 2ef1865
  • Loading branch information
tehnick committed Mar 18, 2024
1 parent e70b6c1 commit 6d337c3
Show file tree
Hide file tree
Showing 286 changed files with 1,935 additions and 1,530 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: '^3rdparty|COPYING|.gitmodules'
exclude: '^3rdparty|COPYING|.gitmodules|src/libpsi/tools/zip/minizip'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
Expand Down
3 changes: 3 additions & 0 deletions 3rdparty/http-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
HTTP Parser
===========

http-parser is [**not** actively maintained](https://github.com/nodejs/http-parser/issues/522).
New projects and projects looking to migrate should consider [llhttp](https://github.com/nodejs/llhttp).

[![Build Status](https://api.travis-ci.org/nodejs/http-parser.svg?branch=master)](https://travis-ci.org/nodejs/http-parser)

This is a parser for HTTP messages written in C. It parses both requests and
Expand Down
14 changes: 14 additions & 0 deletions 3rdparty/http-parser/fuzzers/fuzz_url.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "http_parser.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
struct http_parser_url u;
http_parser_url_init(&u);
http_parser_parse_url((char*)data, size, 0, &u);
http_parser_parse_url((char*)data, size, 1, &u);

return 0;
}
29 changes: 18 additions & 11 deletions 3rdparty/http-parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ size_t http_parser_execute (http_parser *parser,
const char *status_mark = 0;
enum state p_state = (enum state) parser->state;
const unsigned int lenient = parser->lenient_http_headers;
const unsigned int allow_chunked_length = parser->allow_chunked_length;

uint32_t nread = parser->nread;

/* We're in an error state. Don't bother doing anything. */
Expand Down Expand Up @@ -731,7 +733,7 @@ size_t http_parser_execute (http_parser *parser,
if (ch == CR || ch == LF)
break;
parser->flags = 0;
parser->extra_flags = 0;
parser->uses_transfer_encoding = 0;
parser->content_length = ULLONG_MAX;

if (ch == 'H') {
Expand Down Expand Up @@ -769,7 +771,7 @@ size_t http_parser_execute (http_parser *parser,
if (ch == CR || ch == LF)
break;
parser->flags = 0;
parser->extra_flags = 0;
parser->uses_transfer_encoding = 0;
parser->content_length = ULLONG_MAX;

if (ch == 'H') {
Expand Down Expand Up @@ -927,7 +929,7 @@ size_t http_parser_execute (http_parser *parser,
if (ch == CR || ch == LF)
break;
parser->flags = 0;
parser->extra_flags = 0;
parser->uses_transfer_encoding = 0;
parser->content_length = ULLONG_MAX;

if (UNLIKELY(!IS_ALPHA(ch))) {
Expand Down Expand Up @@ -1341,7 +1343,7 @@ size_t http_parser_execute (http_parser *parser,
parser->header_state = h_general;
} else if (parser->index == sizeof(TRANSFER_ENCODING)-2) {
parser->header_state = h_transfer_encoding;
parser->extra_flags |= F_TRANSFER_ENCODING >> 8;
parser->uses_transfer_encoding = 1;
}
break;

Expand Down Expand Up @@ -1801,14 +1803,19 @@ size_t http_parser_execute (http_parser *parser,
REEXECUTE();
}

/* Cannot us transfer-encoding and a content-length header together
/* Cannot use transfer-encoding and a content-length header together
per the HTTP specification. (RFC 7230 Section 3.3.3) */
if ((parser->extra_flags & (F_TRANSFER_ENCODING >> 8)) &&
if ((parser->uses_transfer_encoding == 1) &&
(parser->flags & F_CONTENTLENGTH)) {
/* Allow it for lenient parsing as long as `Transfer-Encoding` is
* not `chunked`
* not `chunked` or allow_length_with_encoding is set
*/
if (!lenient || (parser->flags & F_CHUNKED)) {
if (parser->flags & F_CHUNKED) {
if (!allow_chunked_length) {
SET_ERRNO(HPE_UNEXPECTED_CONTENT_LENGTH);
goto error;
}
} else if (!lenient) {
SET_ERRNO(HPE_UNEXPECTED_CONTENT_LENGTH);
goto error;
}
Expand Down Expand Up @@ -1889,7 +1896,7 @@ size_t http_parser_execute (http_parser *parser,
/* chunked encoding - ignore Content-Length header,
* prepare for a chunk */
UPDATE_STATE(s_chunk_size_start);
} else if (parser->extra_flags & (F_TRANSFER_ENCODING >> 8)) {
} else if (parser->uses_transfer_encoding == 1) {
if (parser->type == HTTP_REQUEST && !lenient) {
/* RFC 7230 3.3.3 */

Expand Down Expand Up @@ -2165,7 +2172,7 @@ http_message_needs_eof (const http_parser *parser)
}

/* RFC 7230 3.3.3, see `s_headers_almost_done` */
if ((parser->extra_flags & (F_TRANSFER_ENCODING >> 8)) &&
if ((parser->uses_transfer_encoding == 1) &&
(parser->flags & F_CHUNKED) == 0) {
return 1;
}
Expand Down Expand Up @@ -2517,7 +2524,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
end = buf + off + len;

/* NOTE: The characters are already validated and are in the [0-9] range */
assert(off + len <= buflen && "Port number overflow");
assert((size_t) (off + len) <= buflen && "Port number overflow");
v = 0;
for (p = buf + off; p < end; p++) {
v *= 10;
Expand Down
12 changes: 9 additions & 3 deletions 3rdparty/http-parser/http_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#elif (defined(__sun) || defined(__sun__)) && defined(__SunOS_5_9)
#include <sys/inttypes.h>
#else
#include <stdint.h>
#endif
Expand Down Expand Up @@ -225,7 +227,6 @@ enum flags
, F_UPGRADE = 1 << 5
, F_SKIPBODY = 1 << 6
, F_CONTENTLENGTH = 1 << 7
, F_TRANSFER_ENCODING = 1 << 8 /* Never set in http_parser.flags */
};


Expand Down Expand Up @@ -300,11 +301,16 @@ struct http_parser {
unsigned int state : 7; /* enum state from http_parser.c */
unsigned int header_state : 7; /* enum header_state from http_parser.c */
unsigned int index : 5; /* index into current matcher */
unsigned int extra_flags : 2;
unsigned int uses_transfer_encoding : 1; /* Transfer-Encoding header is present */
unsigned int allow_chunked_length : 1; /* Allow headers with both
* `Content-Length` and
* `Transfer-Encoding: chunked` set */
unsigned int lenient_http_headers : 1;

uint32_t nread; /* # bytes read in various scenarios */
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
uint64_t content_length; /* # bytes in body. `(uint64_t) -1` (all bits one)
* if no Content-Length header.
*/

/** READ-ONLY **/
unsigned short http_major;
Expand Down
Loading

0 comments on commit 6d337c3

Please sign in to comment.