summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2024-10-23 20:06:18 +0000
committerHauke Mehrtens2025-08-23 14:11:27 +0000
commite61d2be87ba1b72a4bcb66b29449e80458c58875 (patch)
tree73135788b13cd2fac3033986343e4f5d8846a05a
parent8b320f99ac6f8fb24092183f11b5948d7e00495e (diff)
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 <ericfahlgren@gmail.com> Reported-by: Eric Fahlgren <ericfahlgren@gmail.com> Fixes: #6 Signed-off-by: Daniel Golle <daniel@makrotopia.org> Link: https://github.com/openwrt/rpcd/pull/8 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--sys.c3
1 files changed, 1 insertions, 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)) {