Skip to content

Commit

Permalink
CA-406953: Fix pointer truncation in assert code
Browse files Browse the repository at this point in the history
The assert here checks for alignment, so technically truncating the upper bits is not wrong,
but use the correct size.

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Feb 21, 2025
1 parent a76d19f commit 3cd2d4f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/statefileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
Expand Down Expand Up @@ -354,7 +355,7 @@ sf_checksum(
{
MTC_U32 sum = 0;

assert((((MTC_U32)p) & 3) == 0 && (((MTC_U32)end) & 3) == 0);
assert((((uintptr_t)p) & 3) == 0 && (((uintptr_t)end) & 3) == 0);

while (p < end)
{
Expand Down

0 comments on commit 3cd2d4f

Please sign in to comment.