Imported Upstream version 1.4.16+git20130902
This commit is contained in:
parent
e76be63abf
commit
e70fb8c051
517 changed files with 44015 additions and 43295 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <stdarg.h>
|
||||
#include "utils_base.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define np_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } }
|
||||
|
||||
|
@ -35,7 +36,7 @@ nagios_plugin *this_nagios_plugin=NULL;
|
|||
|
||||
void np_init( char *plugin_name, int argc, char **argv ) {
|
||||
if (this_nagios_plugin==NULL) {
|
||||
this_nagios_plugin = malloc(sizeof(nagios_plugin));
|
||||
this_nagios_plugin = calloc(1, sizeof(nagios_plugin));
|
||||
if (this_nagios_plugin==NULL) {
|
||||
die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
|
||||
strerror(errno));
|
||||
|
@ -108,7 +109,7 @@ range
|
|||
double end;
|
||||
char *end_str;
|
||||
|
||||
temp_range = (range *) malloc(sizeof(range));
|
||||
temp_range = (range *) calloc(1, sizeof(range));
|
||||
|
||||
/* Set defaults */
|
||||
temp_range->start = 0;
|
||||
|
@ -154,7 +155,7 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
|
|||
{
|
||||
thresholds *temp_thresholds = NULL;
|
||||
|
||||
if ((temp_thresholds = malloc(sizeof(thresholds))) == NULL)
|
||||
if ((temp_thresholds = calloc(1, sizeof(thresholds))) == NULL)
|
||||
die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
|
||||
strerror(errno));
|
||||
|
||||
|
@ -335,13 +336,13 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
|
|||
if (tmp = index(varlist, sep)) {
|
||||
/* Value is delimited by a comma */
|
||||
if (tmp-varlist == 0) continue;
|
||||
value = (char *)malloc(tmp-varlist+1);
|
||||
value = (char *)calloc(1, tmp-varlist+1);
|
||||
strncpy(value, varlist, tmp-varlist);
|
||||
value[tmp-varlist] = '\0';
|
||||
} else {
|
||||
/* Value is delimited by a \0 */
|
||||
if (strlen(varlist) == 0) continue;
|
||||
value = (char *)malloc(strlen(varlist) + 1);
|
||||
value = (char *)calloc(1, strlen(varlist) + 1);
|
||||
strncpy(value, varlist, strlen(varlist));
|
||||
value[strlen(varlist)] = '\0';
|
||||
}
|
||||
|
@ -431,7 +432,7 @@ void np_enable_state(char *keyname, int expected_data_version) {
|
|||
if(this_nagios_plugin==NULL)
|
||||
die(STATE_UNKNOWN, _("This requires np_init to be called"));
|
||||
|
||||
this_state = (state_key *) malloc(sizeof(state_key));
|
||||
this_state = (state_key *) calloc(1, sizeof(state_key));
|
||||
if(this_state==NULL)
|
||||
die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
|
||||
strerror(errno));
|
||||
|
@ -482,7 +483,7 @@ state_data *np_state_read() {
|
|||
statefile = fopen( this_nagios_plugin->state->_filename, "r" );
|
||||
if(statefile!=NULL) {
|
||||
|
||||
this_state_data = (state_data *) malloc(sizeof(state_data));
|
||||
this_state_data = (state_data *) calloc(1, sizeof(state_data));
|
||||
if(this_state_data==NULL)
|
||||
die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
|
||||
strerror(errno));
|
||||
|
@ -517,7 +518,7 @@ int _np_state_read_file(FILE *f) {
|
|||
time(¤t_time);
|
||||
|
||||
/* Note: This introduces a limit of 1024 bytes in the string data */
|
||||
line = (char *) malloc(1024);
|
||||
line = (char *) calloc(1, 1024);
|
||||
if(line==NULL)
|
||||
die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
|
||||
strerror(errno));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue