Commit ddd4bd7
fix: bound HTTP response reads and use sync.Once for config init (#16)
* fix(main): bound HTTP response reads and use sync.Once for config init
- Limit all HTTP response body reads to 1 MB using io.LimitReader to prevent memory exhaustion
- Replace non-thread-safe configInitialized bool with sync.Once for safe concurrent initialization
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(http): detect oversized responses instead of silent truncation
- Add readResponseBody helper with explicit size limit detection
- Replace 5 inline io.LimitReader calls with the shared helper
- Return errResponseTooLarge for responses exceeding 1MB
- Add unit tests for boundary, oversized, small, and empty responses
- Add end-to-end test for oversized response in requestDeviceCode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent b1def4f commit ddd4bd7
2 files changed
Lines changed: 120 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
46 | 65 | | |
47 | 66 | | |
48 | 67 | | |
| |||
107 | 126 | | |
108 | 127 | | |
109 | 128 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
114 | 133 | | |
| 134 | + | |
115 | 135 | | |
116 | 136 | | |
117 | 137 | | |
| |||
438 | 458 | | |
439 | 459 | | |
440 | 460 | | |
441 | | - | |
| 461 | + | |
442 | 462 | | |
443 | 463 | | |
444 | 464 | | |
| |||
633 | 653 | | |
634 | 654 | | |
635 | 655 | | |
636 | | - | |
| 656 | + | |
637 | 657 | | |
638 | 658 | | |
639 | 659 | | |
| |||
691 | 711 | | |
692 | 712 | | |
693 | 713 | | |
694 | | - | |
| 714 | + | |
695 | 715 | | |
696 | 716 | | |
697 | 717 | | |
| |||
741 | 761 | | |
742 | 762 | | |
743 | 763 | | |
744 | | - | |
| 764 | + | |
745 | 765 | | |
746 | 766 | | |
747 | 767 | | |
| |||
869 | 889 | | |
870 | 890 | | |
871 | 891 | | |
872 | | - | |
| 892 | + | |
873 | 893 | | |
874 | 894 | | |
875 | 895 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
579 | 581 | | |
580 | 582 | | |
581 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
0 commit comments