Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ export function version(cacheKey) {
const byte = digestBuffer.readUInt8(i);
shiftCounter += 8;
// eslint-disable-next-line operator-assignment,no-bitwise
residue = (byte << (shiftCounter - 8)) | residue;
// Use >>> 0 to ensure unsigned 32-bit integer after the OR operation,
// preventing negative values when high bits are set (byte >= 128 with shift >= 24)
// eslint-disable-next-line operator-assignment,no-bitwise
residue = ((byte << (shiftCounter - 8)) | residue) >>> 0;
// eslint-disable-next-line no-bitwise
while (residue >> 5) {
// Use >>> (unsigned right shift) to ensure proper comparison and shifting
// of unsigned values, preventing infinite loops with negative residues
// eslint-disable-next-line operator-assignment,no-bitwise
while (residue >>> 5) {
result += hashCharset.charAt(residue % 32);
shiftCounter -= 5;
// eslint-disable-next-line operator-assignment,no-bitwise
residue = residue >> 5;
residue = residue >>> 5;
}
}

Expand Down
Loading
Loading