--- src/libs/zbxsysinfo/common/net.c 2018-08-28 18:33:58.495308195 +0300 +++ src/libs/zbxsysinfo/common/net.c.with_padding 2018-08-28 18:27:58.202092551 +0300 @@ -189,7 +189,14 @@ struct in_addr inaddr; #ifndef _WINDOWS #ifdef HAVE_RES_NINIT - struct __res_state res_state_local; + /* It seems that on some AIX systems without updates installed res_ninit() can corrupt */ + /* stack causing a crash (see ZBX-14559). Adding some padding bytes helps to avoid crash. */ + struct { + struct __res_state res_state; +#ifdef _AIX + char padding[128]; +#endif + } rs; #else /* thread-unsafe resolver API */ int saved_nscount = 0, saved_retrans, saved_retry; unsigned long saved_options; @@ -470,8 +477,8 @@ } #else /* not _WINDOWS */ #ifdef HAVE_RES_NINIT - memset(&res_state_local, 0, sizeof(res_state_local)); - if (-1 == res_ninit(&res_state_local)) /* initialize always, settings might have changed */ + memset(&rs.res_state, 0, sizeof(rs.res_state)); + if (-1 == res_ninit(&rs.res_state)) /* initialize always, settings might have changed */ #else if (-1 == res_init()) /* initialize always, settings might have changed */ #endif @@ -481,7 +488,7 @@ } #ifdef HAVE_RES_NINIT - if (-1 == (res = res_nmkquery(&res_state_local, QUERY, zone, C_IN, type, NULL, 0, NULL, buf, sizeof(buf)))) + if (-1 == (res = res_nmkquery(&rs.res_state, QUERY, zone, C_IN, type, NULL, 0, NULL, buf, sizeof(buf)))) #else if (-1 == (res = res_mkquery(QUERY, zone, C_IN, type, NULL, 0, NULL, buf, sizeof(buf)))) #endif @@ -499,10 +506,10 @@ } #ifdef HAVE_RES_NINIT - res_state_local.nsaddr_list[0].sin_addr = inaddr; - res_state_local.nsaddr_list[0].sin_family = AF_INET; - res_state_local.nsaddr_list[0].sin_port = htons(ZBX_DEFAULT_DNS_PORT); - res_state_local.nscount = 1; + rs.res_state.nsaddr_list[0].sin_addr = inaddr; + rs.res_state.nsaddr_list[0].sin_family = AF_INET; + rs.res_state.nsaddr_list[0].sin_port = htons(ZBX_DEFAULT_DNS_PORT); + rs.res_state.nscount = 1; #else /* thread-unsafe resolver API */ memcpy(&saved_ns, &(_res.nsaddr_list[0]), sizeof(struct sockaddr_in)); saved_nscount = _res.nscount; @@ -516,16 +523,16 @@ #ifdef HAVE_RES_NINIT if (0 != use_tcp) - res_state_local.options |= RES_USEVC; + rs.res_state.options |= RES_USEVC; - res_state_local.retrans = retrans; - res_state_local.retry = retry; + rs.res_state.retrans = retrans; + rs.res_state.retry = retry; - res = res_nsend(&res_state_local, buf, res, answer.buffer, sizeof(answer.buffer)); + res = res_nsend(&rs.res_state, buf, res, answer.buffer, sizeof(answer.buffer)); # if HAVE_RES_NDESTROY - res_ndestroy(&res_state_local); + res_ndestroy(&rs.res_state); # else - res_nclose(&res_state_local); + res_nclose(&rs.res_state); # endif #else /* thread-unsafe resolver API */ saved_options = _res.options;