Skip to content

Commit

Permalink
sys: use strstr() to detect installed packages
Browse files Browse the repository at this point in the history
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: openwrt#6
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Oct 23, 2024
1 parent 9f4b86e commit 9fd48a1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 9fd48a1

Please sign in to comment.