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);