Health could not read properly the health silencers file (#6374)
* Health_alert The file health/healht.c on line 56 did not check the return of the fread , so Netdata could work with incomplete data * Health_alert The free functions was initially called in a wrong place.
This commit is contained in:
parent
bbb33ab418
commit
9d41bd6ff2
|
@ -53,11 +53,16 @@ void health_silencers_init(void) {
|
|||
if (fd) {
|
||||
char *str = mallocz((length+1)* sizeof(char));
|
||||
if(str) {
|
||||
fread(str, sizeof(char), length, fd);
|
||||
str[length] = 0x00;
|
||||
json_parse(str, NULL, health_silencers_json_read_callback);
|
||||
size_t copied;
|
||||
copied = fread(str, sizeof(char), length, fd);
|
||||
if (copied == (length* sizeof(char))) {
|
||||
str[length] = 0x00;
|
||||
json_parse(str, NULL, health_silencers_json_read_callback);
|
||||
info("Parsed health silencers file %s", silencers_filename);
|
||||
} else {
|
||||
error("Cannot read the data from health silencers file %s", silencers_filename);
|
||||
}
|
||||
freez(str);
|
||||
info("Parsed health silencers file %s", silencers_filename);
|
||||
}
|
||||
fclose(fd);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue