From 9f80b256e67a8c2c4755e0b66ae0e83abd74796a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 18 May 2023 16:38:09 +0200 Subject: Merging upstream version 1.39.1. Signed-off-by: Daniel Baumann --- collectors/proc.plugin/proc_diskstats.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'collectors/proc.plugin/proc_diskstats.c') diff --git a/collectors/proc.plugin/proc_diskstats.c b/collectors/proc.plugin/proc_diskstats.c index 2a4fe4f8c..09c6498e3 100644 --- a/collectors/proc.plugin/proc_diskstats.c +++ b/collectors/proc.plugin/proc_diskstats.c @@ -348,7 +348,7 @@ static inline int get_disk_name_from_path(const char *path, char *result, size_t int found = 0, preferred = 0; - char *first_result = mallocz(result_size); + char *first_result = mallocz(result_size + 1); DIR *dir = opendir(path); if (!dir) { @@ -454,7 +454,7 @@ failed: } static inline char *get_disk_name(unsigned long major, unsigned long minor, char *disk) { - char result[FILENAME_MAX + 1] = ""; + char result[FILENAME_MAX + 2] = ""; if(!path_to_device_mapper || !*path_to_device_mapper || !get_disk_name_from_path(path_to_device_mapper, result, FILENAME_MAX + 1, major, minor, disk, NULL, 0)) if(!path_to_device_label || !*path_to_device_label || !get_disk_name_from_path(path_to_device_label, result, FILENAME_MAX + 1, major, minor, disk, NULL, 0)) @@ -615,8 +615,8 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis // read device uuid if it is an LVM volume if (!strncmp(d->device, "dm-", 3)) { char uuid_filename[FILENAME_MAX + 1]; - snprintfz(uuid_filename, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk); - strncat(uuid_filename, "/dm/uuid", FILENAME_MAX); + int size = snprintfz(uuid_filename, FILENAME_MAX, path_to_sys_devices_virtual_block_device, disk); + strncat(uuid_filename, "/dm/uuid", FILENAME_MAX - size); char device_uuid[RRD_ID_LENGTH_MAX + 1]; if (!read_file(uuid_filename, device_uuid, RRD_ID_LENGTH_MAX) && !strncmp(device_uuid, "LVM-", 4)) { -- cgit v1.2.3