Fix problems in watchdog processing json data.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 13 Mar 2020 01:36:17 +0000 (10:36 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 13 Mar 2020 01:47:07 +0000 (10:47 +0900)
commit5cd6fbcd4d339805836bd2e17d65726833b24aa9
tree89946727e6859cdc4cb2f7e5c5ec5fe794a17823
parentc4ea40d539838b398e343f71efccbcb4130e83af
Fix problems in watchdog processing json data.

Comment on the patch from the author:

In the watchdog source code (src/watchdog/wd_json_data.c), there are some instances of bad handling of values read from json data.
For example:
1) The boolean pool configuration settings "load_balance_mode" and "master_slave_mode" are read using json_get_int_value_for_key(), resulting in 4-bytes being written into their location within the POOL_CONFIG, yet (being bool) they are only 1-byte long. This corrupts the values of the structure members following them.
2) Similarly, when parsing node function json data, "Flags" is read using json_get_int_value_for_key(), resulting in 4-bytes being written into an "unsigned char flags" variable on the stack, overwriting 3-bytes of stack memory following it. On a big-endian system (e.g. Solaris-sparc or Linux for IBM Z), this causes regression test "013.watchdog_failover_require_consensus" to fail, since 0 is written into Flags, rather than the intended value which is in the least significant byte of the int value written.

Bug reported in:
https://www.pgpool.net/mantisbt/view.php?id=596

Patch author:
Greg Nancarrow (Fujitsu Australia)
src/watchdog/wd_json_data.c