[openwrt/openwrt] ucode: fix EOF detection in the non-blocking read patch
LEDE Commits
lede-commits at lists.infradead.org
Thu Oct 16 11:59:21 PDT 2025
nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/2d067b0dd545825d66497b78487135ee887cab6b
commit 2d067b0dd545825d66497b78487135ee887cab6b
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Thu Oct 16 18:57:51 2025 +0000
ucode: fix EOF detection in the non-blocking read patch
size = 0 means EOF - do not return an empty string in this case
(which implies no data available).
Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
.../121-fs-add-read_nb-method-for-non-blocking-reads.patch | 10 +++++++---
...-fs-add-mkdtemp-method-for-creating-temporary-directo.patch | 4 ++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/package/utils/ucode/patches/121-fs-add-read_nb-method-for-non-blocking-reads.patch b/package/utils/ucode/patches/121-fs-add-read_nb-method-for-non-blocking-reads.patch
index 8566ad158b..f258869239 100644
--- a/package/utils/ucode/patches/121-fs-add-read_nb-method-for-non-blocking-reads.patch
+++ b/package/utils/ucode/patches/121-fs-add-read_nb-method-for-non-blocking-reads.patch
@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
--- a/lib/fs.c
+++ b/lib/fs.c
-@@ -674,6 +674,112 @@ uc_fs_read(uc_vm_t *vm, size_t nargs)
+@@ -674,6 +674,116 @@ uc_fs_read(uc_vm_t *vm, size_t nargs)
}
/**
@@ -65,6 +65,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
+ FILE **fp = uc_fn_this("fs.file");
+ char *buf = NULL;
+ ssize_t n_read;
++ uc_value_t *rv;
+ size_t limit = 4096;
+ int fd;
+
@@ -113,7 +114,10 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
+ err_return(errno);
+ }
+
-+ uc_value_t *rv = ucv_string_new_length(buf, (size_t)n_read);
++ if (!n_read)
++ return NULL;
++
++ rv = ucv_string_new_length(buf, (size_t)n_read);
+ free(buf);
+
+ return rv;
@@ -123,7 +127,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
* Writes a chunk of data to the file handle.
*
* In case the given data is not a string, it is converted to a string before
-@@ -2910,6 +3016,7 @@ static const uc_function_list_t proc_fns
+@@ -2910,6 +3020,7 @@ static const uc_function_list_t proc_fns
static const uc_function_list_t file_fns[] = {
{ "read", uc_fs_read },
diff --git a/package/utils/ucode/patches/122-fs-add-mkdtemp-method-for-creating-temporary-directo.patch b/package/utils/ucode/patches/122-fs-add-mkdtemp-method-for-creating-temporary-directo.patch
index a92dac3f43..e6da8bf525 100644
--- a/package/utils/ucode/patches/122-fs-add-mkdtemp-method-for-creating-temporary-directo.patch
+++ b/package/utils/ucode/patches/122-fs-add-mkdtemp-method-for-creating-temporary-directo.patch
@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
--- a/lib/fs.c
+++ b/lib/fs.c
-@@ -2632,6 +2632,86 @@ uc_fs_mkstemp(uc_vm_t *vm, size_t nargs)
+@@ -2636,6 +2636,86 @@ uc_fs_mkstemp(uc_vm_t *vm, size_t nargs)
}
/**
@@ -97,7 +97,7 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
* Checks the accessibility of a file or directory.
*
* The optional modes argument specifies the access modes which should be
-@@ -3065,6 +3145,7 @@ static const uc_function_list_t global_f
+@@ -3069,6 +3149,7 @@ static const uc_function_list_t global_f
{ "basename", uc_fs_basename },
{ "lsdir", uc_fs_lsdir },
{ "mkstemp", uc_fs_mkstemp },
More information about the lede-commits
mailing list