From 9fd48a18a933ac0c2eb76ddb7b3df59c1f9445e2 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 --- 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)) {