From 10c6068b3ed5fac90d7a2bf3b76a97496632e97d Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Sat, 30 Dec 2023 15:01:23 +0100 Subject: [PATCH] sensors_parse_chip_name: Initialize path sensors_parse_chip_name claims to overwrite all of result but path is not set. This is generally not a problem when using statically allocated data that is pre-zeroed but the parser uses dynamic allocation and the chip name may contain garbage depending on the specific code flow resulting from compiling the parser. Setting the path was dropped when it was renamed from busname. Fixes: 8896ba3b ("Rename sensors_chip_name.busname to path, as this is what we are using it for by now.") --- lib/data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/data.c b/lib/data.c index a8fd6b6d..8e38f19f 100644 --- a/lib/data.c +++ b/lib/data.c @@ -84,6 +84,7 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res) { char *dash; + memset(res, 0, sizeof(*res)); /* First, the prefix. It's either "*" or a real chip name. */ if (!strncmp(name, "*-", 2)) { res->prefix = SENSORS_CHIP_NAME_PREFIX_ANY;