{{ message }}
Repository navigation
Commit a05023f
src: fix crash on empty, foreign or truncated --snapshot-blob files
`node --snapshot-blob <file> main.js` aborted with an assertion when
the file was empty (`ReadFileSync()` insists on reading one item), was
not a Node.js snapshot (`CHECK_EQ(magic, kMagic)`) or had a zero-length
startup blob, and read past the end of the buffer when a snapshot was
truncated, because `BlobDeserializer` trusted every length field in the
blob. `EmbedderSnapshotData::FromFile()` is documented to return an
empty pointer for an invalid snapshot and crashed the same way.
Bounds-check each read in `BlobDeserializer` and record the failure,
have `SnapshotData::FromBlob()` print why and return false, and let
`ReadFileSync()` return an empty vector for an empty file. Also add the
missing space in the "built with Node.js version" messages.
Refs: #38905
Refs: #47933
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: #65955
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent f2aa27d commit a05023f
5 files changed
Lines changed: 88 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
190 | 194 | | |
191 | | - | |
192 | | - | |
| 195 | + | |
| 196 | + | |
193 | 197 | | |
194 | | - | |
| 198 | + | |
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
| |||
645 | 649 | | |
646 | 650 | | |
647 | 651 | | |
648 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
649 | 656 | | |
650 | 657 | | |
651 | | - | |
| 658 | + | |
| 659 | + | |
652 | 660 | | |
653 | 661 | | |
654 | 662 | | |
| |||
660 | 668 | | |
661 | 669 | | |
662 | 670 | | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
663 | 675 | | |
664 | 676 | | |
665 | 677 | | |
666 | 678 | | |
667 | 679 | | |
668 | 680 | | |
669 | | - | |
| 681 | + | |
670 | 682 | | |
671 | 683 | | |
672 | 684 | | |
| |||
675 | 687 | | |
676 | 688 | | |
677 | 689 | | |
678 | | - | |
| 690 | + | |
679 | 691 | | |
680 | 692 | | |
681 | 693 | | |
| |||
684 | 696 | | |
685 | 697 | | |
686 | 698 | | |
687 | | - | |
| 699 | + | |
688 | 700 | | |
689 | 701 | | |
690 | 702 | | |
| |||

0 commit comments