Skip to content

Commit 7714988

Browse files
committed
Fixing a buffer overflow bug where a pointer to type of size 1 is reinterpret-casted into a pointer to bigger type, then dereferenced.
1 parent 0fc6103 commit 7714988

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Common/DataStructures/FixedBitVector.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ void BVFixed::SetRange(Container* value, BVIndex start, BVIndex len)
250250
BVUnit::BVUnitTContainer* bits;
251251
static_assert(sizeof(Container) == 1 || sizeof(Container) == sizeof(BVUnit::BVUnitTContainer),
252252
"Container is not suitable to represent the calculated value");
253-
if (sizeof(BVUnit::BVUnitTContainer) == 1)
253+
if (sizeof(Container) == 1)
254254
{
255-
temp = *((BVUnit::BVUnitTContainer*)value);
255+
static_assert(sizeof(byte) == 1, "Size of byte should be 1.");
256+
temp = *(byte*)value;
256257
bits = &temp;
257258
}
258259
else

0 commit comments

Comments
 (0)