Skip to content

Commit

Permalink
Fix: crm_simulate: Prevent segfault on arches with 64bit time_t
Browse files Browse the repository at this point in the history
on an s390x system:

 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  ha_set_tm_time (source=0x0, target=0xb188f960) at iso8601.c:1004
 1004        if (source->tm_year > 0) {
 (gdb) bt
 #0  ha_set_tm_time (source=0x0, target=0xb188f960) at iso8601.c:1004
 ClusterLabs#1  crm_time_set_timet (target=0xb188f960, source=source@entry=0x3ffffa670a0) at iso8601.c:1037
 #2  0x0000000080004f26 in get_date (data_set=0x3ffffa67218, data_set=0x3ffffa67218) at crm_simulate.c:72
 #3  0x0000000080003d20 in main (argc=<optimized out>, argv=0x3ffffa67538) at crm_simulate.c:789

This commit fixes the cast in get_date() which would result in incorrect
values for arches with 64bit time_t
  • Loading branch information
gao-yan committed Aug 6, 2015
1 parent eefdc90 commit b6d405d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/crm_simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ char *use_date = NULL;
static void
get_date(pe_working_set_t * data_set)
{
int value = 0;
time_t original_date = 0;
crm_element_value_int(data_set->input, "execution-date", (int*)&original_date);

crm_element_value_int(data_set->input, "execution-date", &value);
original_date = value;

if (use_date) {
data_set->now = crm_time_new(use_date);
Expand Down

0 comments on commit b6d405d

Please sign in to comment.