diff options
author | Andreas Ericsson <ae@op5.se> | 2012-11-02 13:51:09 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2012-11-03 02:25:37 (GMT) |
commit | 364ce21b1048d1125b8d3fd6744661ab581d08c7 (patch) | |
tree | 7450e9bd2d1ee3b0ae4c90e496e9fa28985b3763 /plugins/utils.c | |
parent | bd782990566eec91b8312cfc2765a7e2bd9e67da (diff) | |
download | monitoring-plugins-364ce21b1048d1125b8d3fd6744661ab581d08c7.tar.gz |
lib/utils_base.c: Stop dumping core on bad args to check_snmp
Since the state patch introduction, we've been freeing uninitialized
memory in lib/utils_base.c::np_cleanup(), which caused coredumps
with check_snmp when illegal threshold ranges (for example) were
passed, or when we called 'die' without having read any state.
This patch fixes it by replacing the malloc() calls in there (all of
them, since using malloc() is almost always an error) with calloc().
malloc() either doesn't initialize the memory at all, or taints it
with a special marker so it can tell us when we're free()'ing memory
that hasn't been initialized. calloc() explicitly initializes the
allocated memory to nul bytes, which is a zero-cost operation when
we get the memory from the kernel (which alread does that) and almost
always desirable everywhere else.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'plugins/utils.c')
0 files changed, 0 insertions, 0 deletions