src: check return value of ftell()

If ftell() returns -1L, abort instead of passing static_cast<size_t>(-1)
to the vector allocator and fread().

Refs: https://github.com/nodejs/node/pull/46463
PR-URL: https://github.com/nodejs/node/pull/46495
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Tobias Nießen authored and GitHub committed 2023-02-06 14:59:36 +00:00
1 parent 8a4b1c9636
commit 1e9ca451c1
1 file changed
+1
+1
View File
@@ -877,6 +877,7 @@ bool SnapshotData::FromBlob(SnapshotData* out, FILE* in) {
int err = fseek(in, 0, SEEK_END);
CHECK_EQ(err, 0);
size_t size = ftell(in);
CHECK_NE(size, static_cast<size_t>(-1L));
err = fseek(in, 0, SEEK_SET);
CHECK_EQ(err, 0);