From 39d66e5280d5eaf80db2b85c62c233aa0dbb23b9 Mon Sep 17 00:00:00 2001 From: monoid Date: Wed, 30 Oct 2024 02:19:24 +0900 Subject: [PATCH] fix: oshash exception --- packages/server/src/util/oshash.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/server/src/util/oshash.ts b/packages/server/src/util/oshash.ts index 1dd78cb..c2a9105 100644 --- a/packages/server/src/util/oshash.ts +++ b/packages/server/src/util/oshash.ts @@ -20,6 +20,10 @@ export async function oshash( let hash = BigInt(st.size); if (st.size < minFileSize){ + if (st.size < 8) { + fd.close(); + throw new Error("Too short to hash"); + } // Although the original oshash algorithm should throw an exception, // just applying the hash function. const chunk = new Uint8Array(st.size);