luci-base: http.uc: fix eof detection in temporary upload files
authorJo-Philipp Wich <jo@mein.io>
Mon, 21 Aug 2023 14:37:11 +0000 (16:37 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 21 Aug 2023 14:37:11 +0000 (16:37 +0200)
Binary string comparisons in ucode are currently unsafe, so use the
`length()` function to determine the just read data chunk size in
order to test for end of file.

Fixes: #6530
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/ucode/http.uc

index 579dda3cedcaaa0bd625cace3c685de6fc67a069..e7f64ae6e9fe00bd1981518927565829a14b11ba 100644 (file)
@@ -430,7 +430,7 @@ const Class = {
                for (let name, value in this.message.params) {
                        while (value?.fd) {
                                let data = value.fd.read(1024);
-                               let eof = (data == null || data == '');
+                               let eof = (length(data) == 0);
 
                                this.filehandler(value, data, eof);