summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-05-31 15:23:14 +0000
committerHauke Mehrtens2026-06-03 23:19:44 +0000
commit46fce7d5efc9c893d37aef47ec8389b0974ce7a9 (patch)
tree3d6106ab6112009be19a6feb1b5dffa39689edb7
parent4fbd48515d6a0c3d8908ce70a09eaac1fb8f7615 (diff)
downloadrpcd-46fce7d5efc9c893d37aef47ec8389b0974ce7a9.tar.gz
ucode: fix off-by-one truncation of generated ubus object type name
rpc_ucode_script_register() builds the ubus object type name "rpcd-plugin-ucode-<object>" into a buffer allocated with "typelen + 1" bytes, where typelen already accounts for the full string length. The snprintf() call however passed "typelen" as the size limit, so snprintf wrote at most typelen-1 characters plus the NUL terminator and silently dropped the last character of every object name from the type string. Pass the actual buffer size (typelen + 1) so the complete name is emitted. Assisted-by: Claude:claude-opus-4-8 Link: https://github.com/openwrt/rpcd/pull/34 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--ucode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ucode.c b/ucode.c
index c6c053b..26be783 100644
--- a/ucode.c
+++ b/ucode.c
@@ -754,7 +754,7 @@ rpc_ucode_script_register(struct ubus_context *ctx, rpc_ucode_script_t *script)
uuobj->script = script;
uuobj->signature = ubus_object_methods;
- snprintf(tnptr, typelen, "rpcd-plugin-ucode-%s", ubus_object_name);
+ snprintf(tnptr, typelen + 1, "rpcd-plugin-ucode-%s", ubus_object_name);
method = (struct ubus_method *)mptr;