@cryptotaxi247 / netdata-1 / commits / dd01f896b

Null terminate string if file read was not successful (#13299)

Stelios Fragkakis committed Jul 5, 2022 at 11:42 UTC dd01f896b466ed8411d58a816db8de2b940f7265
2 files changed +2
database/rrddim.c
+1
@@ -567,6 +567,7 @@ bool rrddim_memory_load_or_create_map_save(RRDSET *st, RRDDIM *rd, RRD_MEMORY_MO
567 now_realtime_timeval(&now);
568
569 int reset = 0;
570 + rd_on_file->magic[sizeof(RRDDIMENSION_MAGIC_V019)] = '\0';
571 if(strcmp(rd_on_file->magic, RRDDIMENSION_MAGIC_V019) != 0) {
572 info("Initializing file %s.", fullfilename);
573 memset(rd_on_file, 0, size);
database/rrdset.c
+1
@@ -1912,6 +1912,7 @@ bool rrdset_memory_load_or_create_map_save(RRDSET *st, RRD_MEMORY_MODE memory_mo
1912
1913 time_t now = now_realtime_sec();
1914
1915 + st_on_file->magic[sizeof(RRDSET_MAGIC_V019)] = '\0';
1916 if(strcmp(st_on_file->magic, RRDSET_MAGIC_V019) != 0) {
1917 info("Initializing file '%s'.", fullfilename);
1918 memset(st_on_file, 0, size);