Skip to content

Commit 153892e

Browse files
authored
Fixing a buffer overflow bug in FixedBitVector (#6715)
1 parent 0fc6103 commit 153892e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ContributionAgreement.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ This agreement has been signed by:
4040
|Yevhen Lukomskyi|ylukomskyi|
4141
|Evgeniy Istomin|MadProbe|
4242
|Wenlu Wang| Kingwl|
43+
|Kevin Cadieux|kevcadieux|

lib/Common/DataStructures/FixedBitVector.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//-------------------------------------------------------------------------------------------------------
2-
// Copyright (C) Microsoft. All rights reserved.
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
34
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
45
//-------------------------------------------------------------------------------------------------------
56
#pragma once
@@ -250,9 +251,10 @@ void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)
250251
BVUnit::BVUnitTContainer* bits;
251252
static_assert(sizeof(Container) == 1 || sizeof(Container) == sizeof(BVUnit::BVUnitTContainer),
252253
"Container is not suitable to represent the calculated value");
253-
if (sizeof(BVUnit::BVUnitTContainer) == 1)
254+
if (sizeof(Container) == 1)
254255
{
255-
temp = *((BVUnit::BVUnitTContainer*)value);
256+
static_assert(sizeof(byte) == 1, "Size of byte should be 1.");
257+
temp = *(byte*)value;
256258
bits = &temp;
257259
}
258260
else

0 commit comments

Comments
 (0)