Skip to content

Commit 3202573

Browse files
committed
- do not use 64bit integer instead of size_t (can't be alloc'ed), or when the actual possible values are 32bit or lower only
1 parent cb8d619 commit 3202573

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sapi/cli/php_http_parser.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ size_t php_http_parser_execute (php_http_parser *parser,
323323
{
324324
char c, ch;
325325
const char *p = data, *pe;
326-
int64_t to_read;
326+
size_t to_read;
327327

328328
enum state state = (enum state) parser->state;
329329
enum header_states header_state = (enum header_states) parser->header_state;
330-
uint64_t index = parser->index;
331-
uint64_t nread = parser->nread;
330+
uint32_t index = parser->index;
331+
uint32_t nread = parser->nread;
332332

333333
/* technically we could combine all of these (except for url_mark) into one
334334
variable, saving stack space, but it seems more clear to have them
@@ -1425,7 +1425,7 @@ size_t php_http_parser_execute (php_http_parser *parser,
14251425
}
14261426

14271427
case s_body_identity:
1428-
to_read = MIN(pe - p, (int64_t)parser->content_length);
1428+
to_read = MIN(pe - p, (size_t)parser->content_length);
14291429
if (to_read > 0) {
14301430
if (settings->on_body) settings->on_body(parser, p, to_read);
14311431
p += to_read - 1;
@@ -1510,7 +1510,7 @@ size_t php_http_parser_execute (php_http_parser *parser,
15101510
{
15111511
assert(parser->flags & F_CHUNKED);
15121512

1513-
to_read = MIN(pe - p, (int64_t)(parser->content_length));
1513+
to_read = MIN(pe - p, (size_t)(parser->content_length));
15141514

15151515
if (to_read > 0) {
15161516
if (settings->on_body) settings->on_body(parser, p, to_read);

sapi/cli/php_http_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct php_http_parser {
112112
unsigned char index;
113113

114114
uint32_t nread;
115-
int64_t content_length;
115+
size_t content_length;
116116

117117
/** READ-ONLY **/
118118
unsigned short http_major;

0 commit comments

Comments
 (0)