From: Daniel Golle Date: Wed, 23 Oct 2024 20:06:18 +0000 (+0100) Subject: sys: use strstr() to detect installed packages X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=e61d2be87ba1b72a4bcb66b29449e80458c58875;p=project%2Frpcd.git 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 --- 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)) {