From f60ad96661857cfa359d632affdbbd39a375e677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 4 Feb 2023 13:15:26 +0000 Subject: [PATCH] src: check return value of ftell() If ftell() returns -1L, abort instead of passing static_cast(-1) to the vector allocator and fread(). Refs: https://github.com/nodejs/node/pull/46463 --- src/node_snapshotable.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index aa66eb331267c4..f2fc879f527633 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -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(-1L)); err = fseek(in, 0, SEEK_SET); CHECK_EQ(err, 0);