mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Fix 2063 (#2079)
This commit is contained in:
@@ -49,8 +49,9 @@ pub fn decodeLenUpperBound(len: usize) usize {
|
||||
|
||||
pub fn decodeLen(source: anytype) usize {
|
||||
return zig_base64.standard.Decoder.calcSizeForSlice(source) catch {
|
||||
//fallback
|
||||
return source.len / 4 * 3;
|
||||
|
||||
//fallback; add 2 to allow for potentially missing padding
|
||||
return source.len / 4 * 3 + 2;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2550,3 +2550,11 @@ it("should not perform out-of-bound access on invalid UTF-8 byte sequence", () =
|
||||
expect(str.length).toBe(6);
|
||||
expect(str).toBe("\uFFFD\x13\x12\x11\x10\x09");
|
||||
});
|
||||
|
||||
it("repro #2063", () => {
|
||||
const buf = Buffer.from("eyJlbWFpbCI6Ijg3MTg4NDYxN0BxcS5jb20iLCJpZCI6OCwicm9sZSI6Im5vcm1hbCIsImlhdCI6MTY3NjI4NDQyMSwiZXhwIjoxNjc2ODg5MjIxfQ", 'base64');
|
||||
expect(buf.length).toBe(85);
|
||||
expect(buf[82]).toBe(50);
|
||||
expect(buf[83]).toBe(49);
|
||||
expect(buf[84]).toBe(125);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user