| 534 | } |
| 535 | |
| 536 | static int DoraXrtHttpParseChunkSize(const char* line, size_t len, size_t* outSize) { |
| 537 | size_t value = 0u; |
| 538 | size_t i = 0u; |
| 539 | int hasDigit = 0; |
| 540 | if (!line || !outSize) { |
| 541 | return 0; |
| 542 | } |
| 543 | while (i < len && line[i] != ';') { |
| 544 | unsigned char ch = (unsigned char)line[i++]; |
| 545 | unsigned int digit; |
| 546 | if (ch >= '0' && ch <= '9') { |
| 547 | digit = ch - '0'; |
| 548 | } else if (ch >= 'a' && ch <= 'f') { |
| 549 | digit = ch - 'a' + 10u; |
| 550 | } else if (ch >= 'A' && ch <= 'F') { |
| 551 | digit = ch - 'A' + 10u; |
| 552 | } else if (isspace(ch)) { |
| 553 | continue; |
| 554 | } else { |
| 555 | return 0; |
| 556 | } |
| 557 | if (value > (SIZE_MAX - digit) / 16u) { |
| 558 | return 0; |
| 559 | } |
| 560 | value = value * 16u + digit; |
| 561 | hasDigit = 1; |
| 562 | } |
| 563 | if (!hasDigit) { |
| 564 | return 0; |
| 565 | } |
| 566 | *outSize = value; |
| 567 | return 1; |
| 568 | } |
| 569 | |
| 570 | static int DoraXrtHttpProcessChunkedTrailers(DoraXrtHttpStreamContext* ctx) { |
| 571 | size_t trailerEnd; |
no outgoing calls
no test coverage detected