Fix: prevent zero padding in writeRandomPadMax16 causing message delivery failures (#1706)

This commit is contained in:
Gustavo Quadri
2025-08-26 06:11:58 -03:00
committed by GitHub
parent fb08f3cadd
commit 478b08bf79
+2 -7
View File
@@ -70,14 +70,9 @@ export const getKeyAuthor = (key: proto.IMessageKey | undefined | null, meId = '
export const writeRandomPadMax16 = (msg: Uint8Array) => {
const pad = randomBytes(1)
const padLength = (pad[0]! & 0x0f) + 1
if (pad[0]) {
pad[0] &= 0xf
} else {
pad[0] = 0xf
}
return Buffer.concat([msg, Buffer.alloc(pad[0], pad[0])])
return Buffer.concat([msg, Buffer.alloc(padLength, padLength)])
}
export const unpadRandomMax16 = (e: Uint8Array | Buffer) => {