From e61d2be87ba1b72a4bcb66b29449e80458c58875 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 23 Oct 2024 21:06:18 +0100 Subject: [PATCH] sys: use strstr() to detect installed packages Don't rely on sscanf() doesn't care about unused suffixes of the status string. Use strstr() instead to make sure only actually installed packages are returned. Suggested-by: Eric Fahlgren Reported-by: Eric Fahlgren Fixes: #6 Signed-off-by: Daniel Golle Link: https://github.com/openwrt/rpcd/pull/8 Signed-off-by: Hauke Mehrtens --- sys.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys.c b/sys.c index da3508e..a41095a 100644 --- a/sys.c +++ b/sys.c @@ -233,8 +233,7 @@ rpc_sys_packagelist(struct ubus_context *ctx, struct ubus_object *obj, break; case 'S': if (is_field("Status", line)) - if (sscanf(line, "Status: install %63s installed", tmp) == 1) - installed = true; + installed = !!strstr(line, " installed"); break; default: if (is_blank(line)) { -- 2.30.2