diff options
| author | Hauke Mehrtens | 2026-04-13 08:28:48 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-03 23:19:08 +0000 |
| commit | ab6549a99c7cc96eb4639aabe7066b898d9c1407 (patch) | |
| tree | 37db235358976f10458a74c4e671dc9ce900a8e9 | |
| parent | 4476687403d8c6e988eaa1ecc892e998838e6da9 (diff) | |
| download | rpcd-ab6549a99c7cc96eb4639aabe7066b898d9c1407.tar.gz | |
file: avoid sending uninitialized stack memory for broken symlinks
When readlink() fails (returns -1), tbuf is left uninitialized.
The unconditional blobmsg_add_string() call that followed would
include whatever happened to be on the stack in the RPC reply,
leaking kernel/stack memory to callers.
Only add the "name" field to the response when readlink() succeeds.
Assisted-by: Claude:claude-sonnet-4-6
Link: https://github.com/openwrt/rpcd/pull/34
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | file.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -579,8 +579,8 @@ rpc_file_list(struct ubus_context *ctx, struct ubus_object *obj, tlen = readlink(entrypath, tbuf, sizeof(tbuf) - 1); if (tlen >= 0) { tbuf[tlen] = '\0'; + blobmsg_add_string(&buf, "name", tbuf); } - blobmsg_add_string(&buf, "name", tbuf); struct stat target; if (!stat(entrypath, &target)) { |