From 1a808a4aad3c864119a5a0bd27b4224775bbb7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 6 Feb 2023 15:59:36 +0100 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 PR-URL: https://github.com/nodejs/node/pull/46495 Reviewed-By: Gireesh Punathil Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Darshan Sen --- src/node_snapshotable.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index 598519c7ba03b1..7ad70447b55206 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);