X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbattery.c;h=f8e67a41aa1735748980f934c651a001747cb1ab;hb=a1dd93a24121e1b11406fdeb94954900bc9774aa;hp=345f606e8f3f834b5398fd15b3c91308607fb4a0;hpb=79e2f5ddc8bffe7ba604530b6090b5d7f7ec9bb1;p=collectd.git diff --git a/src/battery.c b/src/battery.c index 345f606e..f8e67a41 100644 --- a/src/battery.c +++ b/src/battery.c @@ -75,7 +75,7 @@ static int battery_init (void) for (battery_pmu_num = 0; ; battery_pmu_num++) { - len = snprintf (filename, sizeof (filename), battery_pmu_file, battery_pmu_num); + len = ssnprintf (filename, sizeof (filename), battery_pmu_file, battery_pmu_num); if ((len < 0) || ((unsigned int)len >= sizeof (filename))) break; @@ -100,9 +100,10 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl vl.time = time (NULL); strcpy (vl.host, hostname_g); strcpy (vl.plugin, "battery"); - strcpy (vl.plugin_instance, plugin_instance); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void battery_submit */ #if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H @@ -359,11 +360,11 @@ static int battery_read (void) double charge = INVALID_VALUE; double *valptr = NULL; - len = snprintf (filename, sizeof (filename), battery_pmu_file, i); + len = ssnprintf (filename, sizeof (filename), battery_pmu_file, i); if ((len < 0) || ((unsigned int)len >= sizeof (filename))) continue; - len = snprintf (batnum_str, sizeof (batnum_str), "%i", i); + len = ssnprintf (batnum_str, sizeof (batnum_str), "%i", i); if ((len < 0) || ((unsigned int)len >= sizeof (batnum_str))) continue; @@ -435,7 +436,7 @@ static int battery_read (void) if (ent->d_name[0] == '.') continue; - len = snprintf (filename, sizeof (filename), + len = ssnprintf (filename, sizeof (filename), "/proc/acpi/battery/%s/state", ent->d_name); if ((len < 0) || ((unsigned int)len >= sizeof (filename)))