Skip to content

Commit

Permalink
CA-406953: avoid pointer truncation and use of uninitialized values
Browse files Browse the repository at this point in the history
  • Loading branch information
edwintorok committed Feb 21, 2025
6 parents f1f263d + ed3aaf7 + a3cfaa2 + 3cd2d4f + ae864a3 + 1d279d5 commit b081c08
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions daemon/bond_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ bm_initialize(
com_close(bm_object);
bm_object = HA_COMMON_OBJECT_INVALID_HANDLE_VALUE;
#endif
ret = MTC_ERROR_INVALID_PARAMETER;

break;
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ watchdog_selffence(void)
log_message(MTC_LOG_INFO, "watchdog_selffence.\n");

// Attempt to shutdown domain 0 immediately
do_domain_shutdown_self(ret);
do_domain_shutdown_self(MTC_ERROR_HB_FENCEREQUESTED);
// We shouldn't get here but if we do then invoke the watchdog:

if (instance_num == 0)
Expand Down
5 changes: 2 additions & 3 deletions include/mtctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
//

#include <sys/time.h>

#include <stddef.h>

//
//
Expand Down Expand Up @@ -442,8 +442,7 @@ MTC_ASSERT_SIZE(sizeof (void *) == MTC_POINTER_SIZE);

#define _rounddiv(num, div) (((num) + (div) - 1) / (div))
#define _roundup(num, div) (_rounddiv(num, div) * (div))
#define _struct_offset(structname, element) \
((unsigned int)&(((structname *)0)->element))
#define _struct_offset(structname, element) offsetof(structname, element)

#ifndef _min
#define _min(X, Y) ((X < Y)? (X): (Y))
Expand Down
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 b081c08

Please sign in to comment.