Skip to content

Commit

Permalink
Fixing a buffer overflow bug in FixedBitVector (#6715)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevcadieux authored May 20, 2021
1 parent 0fc6103 commit 153892e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions ContributionAgreement.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ This agreement has been signed by:
|Yevhen Lukomskyi|ylukomskyi|
|Evgeniy Istomin|MadProbe|
|Wenlu Wang| Kingwl|
|Kevin Cadieux|kevcadieux|
8 changes: 5 additions & 3 deletions lib/Common/DataStructures/FixedBitVector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
Expand Down Expand Up @@ -250,9 +251,10 @@ void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)
BVUnit::BVUnitTContainer* bits;
static_assert(sizeof(Container) == 1 || sizeof(Container) == sizeof(BVUnit::BVUnitTContainer),
"Container is not suitable to represent the calculated value");
if (sizeof(BVUnit::BVUnitTContainer) == 1)
if (sizeof(Container) == 1)
{
temp = *((BVUnit::BVUnitTContainer*)value);
static_assert(sizeof(byte) == 1, "Size of byte should be 1.");
temp = *(byte*)value;
bits = &temp;
}
else
Expand Down

0 comments on commit 153892e

Please sign in to comment.