mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
fix wrong buffer conversion for Uint8Array (#8787)
If the BufferSource is already an Uint8Array which is a view of a subset of the underlying ArrayBuffer then accessing .buffer caused the whole backing buffer to be returned. Fix this by just returning the original Uint8Array as-is. Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
@@ -17,8 +17,10 @@ export class Fido2Utils {
|
|||||||
return Fido2Utils.fromB64ToArray(Fido2Utils.fromUrlB64ToB64(str));
|
return Fido2Utils.fromB64ToArray(Fido2Utils.fromUrlB64ToB64(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bufferSourceToUint8Array(bufferSource: BufferSource) {
|
static bufferSourceToUint8Array(bufferSource: BufferSource): Uint8Array {
|
||||||
if (Fido2Utils.isArrayBuffer(bufferSource)) {
|
if (bufferSource instanceof Uint8Array) {
|
||||||
|
return bufferSource;
|
||||||
|
} else if (Fido2Utils.isArrayBuffer(bufferSource)) {
|
||||||
return new Uint8Array(bufferSource);
|
return new Uint8Array(bufferSource);
|
||||||
} else {
|
} else {
|
||||||
return new Uint8Array(bufferSource.buffer);
|
return new Uint8Array(bufferSource.buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user