rpc-sys: packagelist: don't truncate input lines on read openwrt-24.10
authorEric Fahlgren <ericfahlgren@gmail.com>
Sat, 23 Aug 2025 21:36:44 +0000 (14:36 -0700)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 31 Aug 2025 23:39:30 +0000 (01:39 +0200)
When the /usr/lib/opkg/status file is read during 'ubus call rpc-sys
packagelist', long input lines are being truncated, which produces
incorrect package lists.  The line read buffer is increased to 512,
which should be able to handle the longest lines in the file.

The 512 value was arrived at by examining the status file on
several devices.  The list of hostapd/wpad conflicts appears to
have be longest line generated in opkg packages, but that second
line of 259 characters containing the dependencies appears to be
the actual root cause of the issues linked below.

Here are the three longest lines I found on all of my installations
(actual output truncated):

$ awk '{print length(), $0}' /usr/lib/opkg/status  | sort -n
 ...
 188 Depends: kernel (= 6.6.93~35ef4dd36891d37023436baa842fa311-r1), ... kmod-lib-crc32c
 259 Depends: hostapd-common (= 2024.09.15~5ace39b0-r2), libc, ... libmbedtls21
 397 Conflicts: hostapd, hostapd-basic, hostapd-basic-openssl, ... wpad-basic-wolfssl

Suggested-by: @hlhintz
Fixes: https://github.com/efahl/owut/issues/28
Fixes: https://github.com/openwrt/rpcd/issues/16
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: https://github.com/openwrt/rpcd/pull/18
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
sys.c

diff --git a/sys.c b/sys.c
index a41095ad2e46162902ade77d747ef36576c5e93f..cd31320945813737878fea2347687da80a1a0e6e 100644 (file)
--- a/sys.c
+++ b/sys.c
@@ -188,7 +188,7 @@ rpc_sys_packagelist(struct ubus_context *ctx, struct ubus_object *obj,
        struct blob_attr *tb[__RPC_PACKAGELIST_MAX];
        bool all = false, installed = false, auto_installed = false;
        struct blob_buf buf = { 0 };
-       char line[256], tmp[128], pkg[128], ver[128];
+       char line[512], tmp[128], pkg[128], ver[128];
        char *pkg_abi;
        void *tbl;