From e9e9d8e3fe64b5b5c1d7ae2ca3913fae2e0b6514 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Sat, 25 Feb 2023 00:02:38 +0300 Subject: [PATCH] libratbag-util: check the return value of scanf --- src/libratbag-util.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libratbag-util.h b/src/libratbag-util.h index cec9aedf..ed431d8e 100644 --- a/src/libratbag-util.h +++ b/src/libratbag-util.h @@ -277,6 +277,7 @@ dpi_list_from_string(const char *str) struct dpi_list *list; unsigned int i, count, index; int nread, dpi = 0; + int rc = 0; char c; void *tmp; @@ -305,8 +306,8 @@ dpi_list_from_string(const char *str) } nread = 0; - sscanf(str, "%d%n", &dpi, &nread); - if (!nread || dpi < 0) + rc = sscanf(str, "%d%n", &dpi, &nread); + if (rc != 1 || !nread || dpi < 0) goto err; list->entries[index] = dpi;