Commit Graph
97 Commits
Author SHA1 Message Date
Felix Fietkau 3e6064bbbf ucode: update to Git HEAD (2026-10-28)
d41981561d7f types: keep tostring exceptions pending during stringification
94562341453a vm: invoke standard library functions internally
a357bc0fd001 compiler: add typeof operator and throw statement
0de223bb2e49 vm, debug: show which function I_STCALL invokes
6004c5aad287 lexer: add a raw text skipper to find the end of a bracketed expression
e915e50fa79c compiler: add destructuring declarations and assignments
a250f159019d rtnl: look up the port attributes by the kind of the master
90b756787ff8 rtnl: decode the slave data of a port with the port attributes
f14b11ba2378 rtnl: send the port data of a link without a link kind
961af31de74a tests: ffi: add calls with complex arguments and return values
3f379cd7d5ed ubus: ignore a channel request after the channel was lost

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-28 15:57:22 +01:00
Sander van Deijck fff992f940 ucode: update to Git HEAD (2026-10-23)
ac11aa287e93 uloop: do not pass exit() requests to the exception guard
1ed0e1b405fe uloop: allow a function to prepare the child in process()
4b561ee2d9b1 build: drop async stack-unwind tables in release builds
0dc287e4795a build: add opt-in link-time optimization for release builds
f46b09a6d61c ffi: guard against unexpected complex widths in uc_ctype_repr_complex()
c92e354def91 ffi: describe struct arguments to libffi properly
34d23a76f3c4 ffi: fix struct descriptors in closures and their lifetime
079a4de01b38 ffi: build without libffi complex number types
4421a403524e tests: skip complex calls without libffi support
11da9228260d types: keep JSON string encoding valid UTF-8
60fe600a50bd struct: advance past whitespace in base64 decoding
5e181347fc5d struct: convert characters before writing them to the buffer

Drop the two uloop patches, which are included upstream now.

Fixes the build of the ffi module on targets whose libffi does not
provide complex types, such as powerpc and riscv.

Signed-off-by: Sander van Deijck <sander@vandeijck.com>
Link: https://github.com/openwrt/openwrt/pull/26143
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-10-25 21:32:39 +01:00
Felix Fietkau a4e922953c ucode: update to Git HEAD (2026-10-18)
f8c2d64f546c uloop: allow reusing the existing environment for a new process
1294001ec6cb uloop: fix array reference
dd91bd8396a5 tests: add test cases for use-after-free gc bugs
d96db3ea5ef2 json: fix use-after-free of read method across iterations
8a74d68a34ab lib: anchor working values in filter/map/callfunc across user code
2225a502e805 socket: anchor poll() result across user fileno() callbacks
6a061cf4ef34 zlib: fix use-after-free of read method across iterations
dbe92bca180b types: free uvcount=0 resources on retain=true sweep
b0574723d27d zlib: zero-fill the output reserve window
cc0698b723ed serial: add module skeleton, build wiring and fd helpers
114ffb8962e2 serial: add raw termios access and termios constants
3bdeeb0b1ef7 serial: add setspeed, setraw and setblocking helpers
2b22a1ac41b0 serial: add modem control line access (out-of-band signals)
bed2a12895ce serial: add break, drain, flush and queue inspection
697fe07b14db serial: add setserial-style serial_struct access (Linux)
504530a290ad serial: add termios round-trip test
d6544940e762 ubus: fix reply leak in deferred data callback
dfca6438bc55 fs: reimplement popen() with fork/exec and true shell-free array support
9a87ce92207a debug: rework memdump to invoke fileno() on resource values
bed321219636 types: expose exception_type_strings array
67b13e97a643 lib: allow die() to re-throw exception objects
f2d62f82a522 lib: deduplicate source files by resolved path in vm->sources cache
255f69081304 socket: add CAN socket support
6adff7054893 rtnl: add CAN link type support
b79e20e1eee5 rtnl: add vxcan link type support
5870b9995ff4 rtnl: zero reserved struct headers in nested attributes
abb80c69ed2d include: add `unused` macro
ff509e0698dc include: register resource type prototypes with VM
c404fe2d6556 types: add per-instance prototype support for extended resources
7fb34544e945 ci: install libffi on test runners
23d5561b04b2 ffi: add LibFFI-based foreign function interface module
f26fabfe3ecb ffi: Add .cast(), .copy(), .string() as ctype instance methods
19ffa8aa3218 vm: release resource type prototypes before the final GC
48e38fc6376f tests: move ffi ctype instance method tests to proper place
4d687afdc216 compiler, vm: implement tail call optimization
7074129727d9 vm: indicate tail call optimized frames in stack traces
c3dc162f0abc lib: reject circular prototype chains in proto()
fe9e2947d351 compiler: reject adjacent template literals
e9972df30d14 linux/types.h: add 128-bit integer types
76baa6fc264a types: fix instance-proto lookup offset in ucv_key_get()
fbdd169efd17 ubus: store per-call request proto in the instance proto slot
0aab97337e21 ubus: drop per-instance proto when releasing resources
4eff16514b57 uloop: report signal termination in process callbacks
9ba6ea147dee headers: split public and private API headers
4c6e64425d14 ffi: reject function values passed as variadic arguments
af69c8d226a9 types, vm, lib: add metamethod support for prototyped values
1fd07aa2ba34 ffi: represent wrapped C functions as "ffi.cfn" resources
c966006d635f ffi, vm: support property syntax for cdata via __get__ / __set__
672439e7c530 vm: add debugger infrastructure (breakpoints, offsets, nested-exit fix)
a5b5925b53ab debug: add interactive command line debugger with -x/-X CLI switches
c2476472eb23 debug: add remote debug protocol with a client/server split
d968d33f455e debug: move the debugger onto a line-based protocol, split server/client
1a771e3c1ffd debug: add line editing, EVAL, Ctrl-C interrupt and tail-call annotations
26bfd5851bcc debug: synthesize PAUSED when a resuming command cannot resume
00a8fa9dea6c ffi: add ffi.closure() for explicit C function pointer creation
f061ee2e4369 ffi: fix Clang static analyzer false positives in closure code
8c017f171f0a types: Fix warning unused variable
0273114f13a6 types: raise type error for non-index array property sets in strict mode
d2c7b24e366e struct: rename ucv_as_double to ucv_as_float64
4dd080fe47ab headers: privatize uc_program_entry/ucv_closure_new/ucv_compare, add uc_program_main()
fda0498102bd lib, vm: replace ad-hoc value casts with ucv_as_* macros
ad88dfb621d6 metamethods: object-valued __get__/__set__/__delete__ delegate instead of mis-delegating return values
ea4c65b3c255 lib/fs.c: set errno on failed open()
10e44a53f808 lib.c: add optional offset argument to index() and rindex()
37d10ce70189 lib/io.c: fix io.pipe() jsdoc example
100f354f5d75 lib/math.c: export math constants (PI, E, ...)
ca70f18e31b3 lib/resolv.c: validate retries/timeout and guard retry-interval division
22f64a32f784 treewide: adjust references after jow-/ucode => ucode-lang/ucode move
6373faeac549 docs: fix deep merge example
1561320a00b4 lib,main,types: include json-c compat shim where needed
83ed2a8ba815 tutorials: fix claims that disagree with the interpreter
cef095d846bd Update CNAME
0c39aaa3d277 lib/log.c: accept arrays of channel and option names
ad3a5d580983 lib/log.c: use the documented defaults for omitted arguments
9e1d747640fe devcontainer: add development container configuration
d2c81218773b vm: clear a pending exception when entering uc_vm_execute
deb063dba30d build: add minimal emscripten/wasm32 build guards
75489e3ca2d5 source: initialize runpath in uc_source_new_buffer
4e65efb46854 build: add emscripten/wasm32 CMake support
24b0a2ad2e05 lib: underline the statement an error occurred in
926a2bf7e219 lib: name the offending expression when a call fails
068e7b222b4f ucode: fix socket bind() ignoring port argument
a4da50de2430 io: read the current termios before applying attributes
38f21be1bcbb uloop: redirect the task child's standard descriptors to /dev/null
af8a3830661a uloop: close the task output pipe even without an input callback
e6e03000000f uloop: release the handle when uloop_fd_add() fails
1e6b56558617 uloop: read task messages without losing them to EAGAIN
6e1592a2862f fs: report a write that only fails when the file is closed
d075095287c8 fs: keep the bytes a short read already delivered
8c01857cadd0 resolv: file each NS, CNAME and PTR record under its own type
4fec71ddd26d struct: decode any non-zero byte as true in native mode
edf5b32c5d4c zlib: inflate every member of a concatenated stream
b844c63b2381 resolv: release the TXT buffer when the record is malformed
664b70791957 compiler: unwind the nested function compiler on a bad argument list
ab988ea3159a struct: accumulate signed integers in an unsigned type
d996fade5f36 compiler: do not overflow int building the wildcard import operand
24df8d20bde2 vm: give division by zero the right sign, and NaN for zero over zero
a5c102ea2cfd tests: expect statement underline in forward declaration error
ccbe4228913d types: clear resource value slots after releasing them
c7e550d05ec4 socket: reject recv() lengths that overflow the printbuf offset
b1c7693fc5c6 socket: do not free caller-owned control data in sendmsg()
0630355f1ce6 socket: size msg_controllen from the payload, not the cmsg length
b51836754a9e types: do not dereference tagged values in ucv_string_length()
8fac388410d4 struct: bound the base64 pack field to the space reserved for it
b8a8646cbb2c struct: bounds-check the field offset when unpacking
5544af285082 struct: allocate the string header when packing zero bytes
8bd004a1a423 lib: free the string match() allocated, not the one it advanced
e98574152fcb io: return ENOMEM rather than aborting on an oversized read
9b45eef92402 io: give ioctl() a heap buffer the kernel cannot overrun
531c09289a4f resolv: check the SOA rdata bound after the two names
4d12bc9af856 ubus: detect cycles when converting values to blobmsg
5bcb94aec84d vallist: reject an inline string constant longer than its buffer
cd73805bcb0f program: validate the export name length when loading bytecode
fe546444f289 program: terminate the strings the bytecode loader reads
ba4b639597e6 compiler: do not return a bytecode program that was just freed
19247f51e22a compiler: unwind the patchlist when an expression fails to parse
58774dd67277 rtnl, nl80211: check every netlink reserve return
8fff82c22a7c fs: stop readfile() losing data when the buffer cannot grow
39454f8830a9 zlib: act on the output reserve failing
a90a1d2c9ebe lib: size the b64dec output buffer from the ceiling
ad3be9a33322 ubus: bound the nesting depth when decoding a message
953cd5a9ea23 ubus: do not close a descriptor the script still owns
5a2c5d93ce53 lexer: discard the partial string when an escape is rejected
428232cfce1c vm: range-check local slots, upvalue indices and stack depth
e170905c143b program: bound the counts and lengths the bytecode loader reads
6065b2ce63cc program: bound an export name by the bytes left in the file
e1a8b8cf5d21 compiler: do not call a missing infix handler inside parentheses
2cd8d1b9726b compiler: do not read the last instruction of an empty chunk
468994d345ff compiler: compare local names without assuming they are strings
04d59c6395de compiler: guard the remaining local name comparisons
19656543aac0 types: dispatch __delete__ for keys arrays and resources cannot store
dd57d12404ec compiler: do not drop the loop condition at chunk offset 0
dc9386a190fb jsdoc: accept a doc comment at the very start of a file
04d3ae59abd4 serial: add JSDoc documentation for module functions and constants
959206e27878 netaddr: add new netaddr module ported from LuCI's luci-lib-ip
904358422b3b docs: restructure tutorials around the new manual
af9324c9e7c5 readme: point at the new project sites
212dd12150b6 lib: optimize trim(), ltrim(), rtrim()
2c8c36be454d struct: fix infinite loop in grow_buffer() for small sizes
131c041a61d5 platform: export the macOS pipe2() replacement to modules
e6a1f945db65 fs: find the PATH separator without strchrnul()
4711d3c2c5dc lib: reject mutations of the container being sorted
f0a4664b97b0 rtnl: recover the event listener from receive buffer overruns
eaa09ca64305 rtnl: free the partial reply of a request that fails
5c655c357c53 rtnl: return true for an acknowledgement without data
0bfb7b97bf2f nl80211: recover the event listener from receive buffer overruns
30dfbb218fa1 nl80211: return true for an acknowledgement without data
395cfeead63f nl80211: fail a request whose reply the event socket lost
f8f8fc55126f nl80211: run listener callbacks outside of a request
f60d9b01b59c nl80211: free the partial reply of a request that fails
234e524f7ae0 nl80211.h: update to mainline d24e8ac715de
80be3ab390ee nl80211: request and decode the per-link statistics of a station
c51e15921dc6 lib: fix module namespace export mapping for linked imports
b5ce44358354 compiler: report strict redeclarations at the redeclaring name
e22e4362e6d5 tests: allow restricting a testcase to platforms
ef5b35ea145e tests: do not check forked children with valgrind
a6b8bfe1b582 tests: allow a testcase to skip itself
7fe06b46f3c5 uloop: expose ULOOP_ERROR_CB
115d308a8514 uloop: release timers and handles once they are finished
0c1b005cd0d3 uloop: disarm a timer on set() without a timeout
986390458007 uloop: disarm an interval on set() without a value
503a9bfcffd2 uloop: test that a finished task closes its pipes
f4fa308dc4f2 uloop: keep a task alive while its output callback runs
fa81c11ff2a7 uloop: release a finished task after a callback exception
21a2140f2324 uloop: reject a handle without an IO event
0ea69b1e736a uloop: do not unregister a reused descriptor number on handle delete
ddb06a197ef5 compiler: make strict mode function names constant bindings
620eff6a772d uloop: keep a handle alive while epoll may still report it
1942e5fce058 uloop: disable a handle whose removal fails
9a3acc008531 uloop: expose ULOOP_PRIORITY
1f54bd285339 uloop: read task messages without blocking the event loop
c2319e9b26bb uloop: close the task pipes when fork() fails
db2191ab014e devcontainer: remove formatting options managed by editorconfig
486104700227 compiler: account for nested imports in the importer's export offset
be870dd61b95 types: give the collector a dedicated mark bit
2e0b25a23c09 socket: fall back to SO_TIMESTAMPNS for the OLD alias
4141cb38f398 ubus: pass an exception of a deferred completion callback to the guard
0fcd31713fee ubus: do not pass exit() in a callback to the guard
c80855059801 socket: fix the file descriptor on 64-bit big-endian
a18924e53045 tests: move the socket poll test to the lib_socket directory
f4ce7eb00d22 source: allocate and release a source in one place
8d25f029d96b compiler: give dynamic loads the position of the import
08f3be072dd0 vm: read the callee type before uc_vm_call() runs it
3c9f214a2d56 serial: add RS485 mode access (Linux)
100d19ac369f vm: keep the exception of a module that failed to load
3c0a3c7c1023 vm: read the importing frame after the module load
2cf103aded34 tests: skip the RS485 serial test under valgrind
5c8d6d544730 lib: fix stack use after scope in compile config parsing
0dc042eefa5b source: rework the text access API
1dd1f88c81bb source: close the file of a source after its compilation
69db946e7c39 lib: remove the source cache of loadfile()
4436a931dc38 compiler: start each compilation from a clean source
4503599e49f1 source: read a file that cannot seek into a buffer
330cdab782be compiler: release the name list of an import() statement
153c627fd445 lib: do not store a failed module in the module table
3bf604919140 vm: keep the exception of a failed dynamic module load
71b4a144b438 lib: compile a file loaded from a module body as a program
080cbd79727f lib: release the main function of a required file
6c30ef7fd30c vm: release the previous binding of an import
6e404de5c0b1 vm: let the main closure of a program own its module exports
0adb7ba6b4d1 vm: do not interrupt the exports of a module
8cfcffe5abcd lib: find the exports of a precompiled module by their count
53ebdff102e6 vm: size object literals from the compiler's key count
f8a757295dc9 types: start array entry vectors at 2 slots
00091f829801 types: avoid accessing values after converter exit
78f83f8d6b59 lib: take one reference on the prototype in proto()
96cdb4549b59 compiler: fix endless loop on syntax errors in template placeholders
fb54dfe1733c types: release the old instance prototype of a resource

struct uc_vm grows at its end, and programs such as hostapd embed it, so
bump PKG_ABI_VERSION.

Add packages for the new ffi, netaddr and serial modules. Turn them off
for the host build, since ffi is otherwise built whenever libffi happens
to be in the staging directory.

The project moved to ucode-lang/ucode, so update PKG_SOURCE_URL.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-19 12:22:07 +02:00
Felix Fietkau ae9276426c ucode: rtnl: return true on acknowledged requests without data
Fixes error handling issues on requests

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-10-09 20:46:24 +02:00
Felix Fietkau 23ac692e6d ucode: update to Git HEAD (2026-07-09)
20a2ae469089 io: support older linux ioctls
16929698e2d3 fs: implement ioctl for macOS
395bb888bd69 io: implement ioctl for macOS
8d7d15ee1a08 compiler: add support for shorthand method declarations
7d9febd13305 nl80211: add mesh peer link enum macros to constants list
e851bb64df91 lib: avoid allocating print buffer before NULL check in uc_error_message_indent
5f3a7b87d962 compiler: prevent unbounded recompilation on failed module imports
e2493b577250 compiler: scope named function expression names to their own body
c3f0d27d812e tests: add regression test for named function expression scoping
738b55299966 vm: release owned value when property assignment fails
1ffd7c5a1011 vm: fix out-of-bounds read in single-name module import
a255256db106 vm: fix SIGFPE on INT64_MIN division and modulo by -1
3f4b313d7d78 vm: do not assign to undeclared variables in strict mode
e523682670a2 vm: release upvalue reference when resolving it on stack push
6a837090bea3 vm: release module scope reference in dynamic import
395a0a16b4f9 vm: guard error context capture against empty callframe stack
04f103bb2270 vm: respect exponent parity in integer exponentiation
bd814a4b2ae3 vm: use UC_ARRAY instead of json_type_array in object spread
5a79aa56c15e vm: release resource type prototypes after the final GC
9c5f16c8e33a lexer: do not treat /*/ as a complete block comment
a018067fd12e lexer: preserve NUL bytes in regular expression literals
65d41a1929de lexer: do not consume a sign into hexadecimal number literals
05f9bf9e5d53 lexer: fix source position of ternary question mark token
7bca646e5f88 lib: preserve embedded NUL bytes in reverse()
6fc93bf5bd95 lib: preserve embedded NUL bytes in lc() and uc()
a51f4843bce5 lib: avoid passing a signed char to isxdigit() in hex()
e8af70e4375c compiler: fix use-after-free of shorthand method name
467fb4406a47 compiler: declare leading variable in counting for loop initializer
d256e153799b rtnl: fix stack buffer overflow parsing IFLA_LINKINFO
f741ac0a144c rtnl: fix stack buffer overflow parsing RTA_MULTIPATH nexthops
c41310f7c2df rtnl: fix inverted address check in multipath nexthop parsing

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-07-16 11:50:22 +02:00
Felix Fietkau 7987b1f799 ucode: fix two compiler issues
- When working with deeply nested imports, compile errors led to long
  error messages or complete hangs by compiling the same module over
  and over again.
- Fix for a function expression scope issue.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-07-07 10:46:12 +02:00
Felix Fietkau 76e6216c8a ucode: update to Git HEAD (2026-06-03)
1ac496a91a30 math: min and max
4c917958038d math: clamp
c6404b6af75c math: sign functions
597b17d0edea math: copysign
9747c8bbfa27 math: floor
933b11802060 math: ceil
46581cf13149 math: round
4aee92d5aa89 math: trunc
c8f71433a3d6 math: log functions
840aa6e61196 math: Infinity handling note
990558c2a027 math: isinf
c3e76e45fdad math: tan
08c6ef98fa2f math: acos, asin, atan
21a0f37d4c7c math: cosh, sinh, tanh
28ec6e4466b5 math: cbrt, hypot
fb2fc094875c math: expm1, log1p
1a911dbc72b0 math: jsdoc fixes
7b3b15dc7d25 math: add double/int output toggle flag to floor/ceil/round/trunc
7424c3bd14e0 make: improve make (install) on macOS
965d76557dee types: release previous prototype reference in ucv_prototype_set
b702323ec137 uloop: unregister task output fd from uloop before closing it
106b1179765a uloop: clear resource values when releasing callback resources
acc70db934fc ubus: clear resource values when releasing connection/object resources
9d7ade9e4c68 ubus: prevent UAF when channel disconnect_cb triggers re-entrant disconnect

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-06-03 13:13:17 +02:00
Felix Fietkau 4ae4759e0b ucode: update to Git HEAD (2026-04-24)
3d999b21f4ba socket: add include for older kernels
552ca3cf55ed compiler: allow export function declarations without trailing semicolon
d9e24e4ad13d compiler: add function forward declaration syntax
de986520017a fs: add statvfs flags and fs error codes
e6bf0a9dca79 nl80211: fix listener.request() dropping multicast events
520d9f4c8781 nl80211: fix waitfor() busy-spinning on non-blocking event socket
05328e33f078 nl80211: fix memory leak in waitfor() on repeated matching events
e4a165976dbb nl80211: don't report waitfor() match on event parse failure
57367e880e9d nl80211: add missing survey info attributes
a39b74fe329e nl80211: fix dfs_cac_time attribute type
beafcff845fc compiler, lib, resolv: fix const string pointers
4170c8dcc568 lib: fix system() inheriting blocked SIGCHLD mask in child process
d2c74298e22d fs: document glob
8a8b4d12a867 types: fix regexp `/.../s` flag inversion
d7bc7adcb99d lib: slightly expand regexp() JSDoc
826fbfef2df9 nl80211: fix HE MCS set parsing
617967a3ceb9 socket: strip brackets from IPv6 addresses in addrinfo()
a078b72a90bb socket: increase IPv6 scope ID buffer to support 15-char interface names
ed23cf5aa182 rtnl, nl80211: fix segfault when listener.close() is called explicitly
3e585662394b docs: add function forward declarations to syntax tutorial
bda4a0e454de vm: free thread context on vm_free to prevent memory leak
13158a73c96b nl80211: get iftype extended capabilites
30ffbd6c07dc ubus: add module documentation
ce0c8fc0ffea docs: spelling fixes and usage notes
35a74e92ad69 docs: rewrite ubus module intro to expand pub/sub and fix OpenWrt capitalization
b3380068a7e1 docs: flatten ubus class hierarchy and fix capitalization
3c9d3b5272d7 docs: math: fix spelling mistakes in documentation
aae2250ab519 fs: fix popen() documentation
eff52f0d262a digest: implement FNV-1a 64 bit hash algorithm
35ed1d1efd64 ubus: fix refcounting bug
c7e7dfa7b64a ubus: avoid double close of externally owned channel fds
896ac72caffb tests: make run_tests.uc default to build/
b50372e8e8a0 tests: implement automatic library test skipping
81066c54a07f math: degrees <-> radians convertors
388ef3f35e0a ubus: drop unconditional garbage collection calls
aebdb2c0262e main: fix option argument parsing on glibc

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-05-04 16:29:36 +02:00
Felix Fietkau 68a35447d9 ucode: nl80211: fix HE MCS parsing
Do not parse an u8 array as u16.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-03-23 10:57:16 +01:00
Felix Fietkau d9ac485146 ucode: nl80211: add missing survey info attributes and fix DFS CAC time
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-03-01 18:41:24 +00:00
Felix Fietkau 94a7c4a443 ucode: update to Git HEAD (2026-02-27)
d768823fea50 vm: rework I_DYNLOAD instruction to read module name from stack
9e265b9a1e15 program: support encoding export symbols in precompiled bytecode
926f20b55e13 compiler: add support for runtime module imports
e3d7d77f0e5d lib: avoid stack operations if required code invoked exit()
7f3a0512f49d compiler: turn static imports of precompiled modules into dynamic loads
ccc25285471b nl80211.h: update to version 6.18
bb145163147a nl80211: add WiFi 7 EHT and MLD attributes
65d268546453 nl80211: add scan, BSS status and BSS use-for constants

Fixes: https://github.com/jow-/ucode/issues/336#issuecomment-3415635374
Fixes: https://github.com/jow-/ucode/pull/338#issuecomment-3442569831
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-03-01 18:41:24 +00:00
Felix Fietkau e9d6025725 ucode: add ubus fixes
- avoid double close of externally owned channel fds
- fix refcounting bug

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-02-07 10:04:17 +01:00
Paul Donald a82738d83f ucode: update to Git 85922056ef7 (2026-01-16)
45bf891e1d8d rtnl: add module documentation
8bbf01215ce3 nl80211: add module documentation
40a6aeb698e1 nl80211: add new attribute "mlo_links" for per link information
376e8733609e ubus: complete pending requests when disconnecting locally
32449bfb69d6 io: add ptsname, tcgetattr, tcsetattr, grantpt, unlockpt
76bf32679d86 digest: fix jsdoc to reveal sha512 functions
58b4597fa2ae build: drop remnant
6ef0b3ada3fd build: respect bin/lib paths
28132276a426 build: adjust flags and definitions
cb1b1c1a097b zlib: make chunk size configurable
6f80655c88c3 debian: refresh packaging
9fc4889c6e8e debian: adjust LTO build
a503a49f5cef debian: build "digest" and "zlib" modules
ffc48a2a4db9 socket: fix off-by-one in uv_to_sockaddr()

Fixes: https://github.com/jow-/ucode/issues/366

dropped patch 130 - integrated at source.
refreshed patches

https://github.com/openwrt/openwrt/pull/21585
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21585
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-01-21 23:50:52 +01:00
Paul Donald 16ae5c23e5 ucode: enable ucode-mod-zlib
The module exists in ucode and has been present for a while
but has not been enabled. It provides the ucode zlib module
for handling gzip and zlib compression in ucode scripts.

The package is ~ 5Kb. Installed ~18Kb.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21417
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-01-19 21:21:17 +01:00
Felix Fietkau e06c4125fd ucode: remove the fs.read_nb patch
It is obsolete since the io module was added

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-01-06 20:09:35 +01:00
Felix Fietkau ed2587c73d ucode: add package for ucode-mod-io
It was included in the last update

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-01-06 20:09:35 +01:00
Felix Fietkau bf46d119a2 ucode-mod-ubus: complete pending requests when disconnecting locally
libubus only completes pending requests when the socket receives EOF.
When explicitly disconnecting, we need to call ubus_flush_requests().

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2026-01-05 12:43:40 +01:00
Hauke Mehrtens e40ca676ee ucode: update to Git HEAD (2025-12-01)
afe4be60628a lib/fs: fix return value for flush
5f08ecf8e372 lib/uloop: fix return value doc for run()
1affe484f302 lib/uloop: pass eof and error to cb
559860cbd76d lib: introduce io library
ef07e2448a56 vm: optimize string+string concat with ucv_string_alloc

Changes: https://github.com/jow-/ucode/compare/48ed18d2532e9197212c34473ab926c7b5e8ac73...f7c2b97a82e8b505bf4b2c0d8883b5116e1960f9

Backport PR to fix compilation with Ubuntu 18.04:
https://github.com/jow-/ucode/pull/355

Link: https://github.com/openwrt/openwrt/pull/21100
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-12-10 23:38:08 +01:00
Hauke Mehrtens 34aa008923 ucode: update to Git HEAD (2025-11-19)
8567eef4d3a5 examples/execute-file: free program
292e0f87cbf7 examples: free syntax_error
fd5889028f5e Revert "nl80211: read all pending event messages"
80a88b852620 types: add ucv_string_alloc helper function

The removed patch was applied upstream.

Link: https://github.com/openwrt/openwrt/pull/20850
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-11-22 12:50:01 +01:00
Hauke Mehrtens 985394bf26 ucode: update to Git HEAD (2025-11-07)
e8a7290e55c0 socket: fix `recv()` incorrectly reporting unrelated errors
ddde611fb9d4 socket: fix convertion of hw addresses to ucode strings
924ccc95be32 vm: make sure uc_vm_insn_to_name() always returns a value
754590d26f23 lexer: fix parsing \xHH and \0OOO escape sequences
623f550e579a fs: add dup2() function
6c9385a99edd fs: add mkdtemp() method for creating temporary directories
ea579046a619 fs: reset errno to zero in get_fd()

The removed patches are integrated upstream.

Fixes: https://github.com/jow-/ucode/issues/332
Fixes: https://github.com/jow-/ucode/issues/337
Link: https://github.com/openwrt/openwrt/pull/20718
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-11-11 21:27:39 +01:00
Felix Fietkau 2d067b0dd5 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@nbd.name>
2025-10-16 20:58:55 +02:00
Felix Fietkau 7dd62db9a9 ucode: revert a broken commit
It causes an infinite loop when polling nl80211 netlink sockets

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-10-14 14:54:26 +02:00
Felix Fietkau 255d999783 ucode: add fs.mkdtemp function
Useful for creating temporary directories

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-10-13 10:56:39 +02:00
Felix Fietkau ad6df8a3c8 ucode: add patches that make it easier to deal with non-blocking fds
This allows creating pipes for subprocesses to use as stdin/out/err
and polling them from a uloop process.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-10-09 09:57:30 +02:00
Felix Fietkau 7418c2d89b ucode: fix reusing the current environment in uloop.process()
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-10-08 19:50:29 +02:00
Felix Fietkau a64db95a23 ucode: fix parsing \xHH and \0OOO escape sequences
Both need to add add bytes, not UTF-8 sequences.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-10-05 11:31:31 +02:00
Felix Fietkau 2f6a467f6c ucode: update to Git HEAD (2025-09-29)
f642f65c3d00 rtnl: optimize string attribute encoding
1946c571eb25 nl80211: rework string attribute encoding
6b16cd37373a nl80211: properly handle decoding numeric struct members
5a342b86c010 nl80211: support sending requests on listener socket
cd2850eec8ca lib: fix `rindex()` return value when needle at the start of the haystack
23b21eb2e8cb ubus: add connection functions to global scope
a5b206f60f5d struct: align `X` and `Z` length & truncation semantics with `*`
387880348c89 nl80211: read all pending event messages
470bc3ebffe0 uloop: fix potential use-after-free when destroying uloop entities

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-09-29 14:09:10 +02:00
Felix Fietkau 5b8f185e27 ucode: ubus: add shared global connection to uloop
Fixes issues with registering objects

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-09-17 12:27:55 +02:00
Felix Fietkau 6f2738df55 ucode: ubus: simplify sharing a global connection state
Add connection methods as global functions

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-09-15 09:59:35 +02:00
Felix Fietkau 90b01086db ucode: update to Git HEAD (2025-08-26)
2ae08749a87e ucode: add padding to uc_resource_ext_t
7931bd901222 socket: add socket.pair()
4cd07cd66ab3 socket: add socket.open()
6350e6383ff3 struct: implement X and Z formats for hex and base64 coding
e632e6da1fbc vm: fix potential eyond end of array accesses
a7ead3169ebf resolv: properly handle multiple TXT strings
9d782ea4af63 math: Add an optional range to rand()

Fixes: https://github.com/jow-/ucode/issues/315
Fixes: https://github.com/jow-/ucode/issues/321
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-09-15 09:59:35 +02:00
Felix Fietkau 6c22e8ef53 ucode: add padding to uc_resource_ext_t
Fixes misaligned allocations for ext resources

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-23 12:16:06 +02:00
Felix Fietkau c39a09686e ucode: update to Git HEAD (2025-07-18)
5b3b6b789b9c ubus: fix refcount issue in uc_ubus_object_notify
f682ac2f6b82 program: add bytecode version to program header flags
af411d8101b2 vm: implement PVAL opcode
afdfffb61258 vm: support initiating method calls with I_CALL/I_QCALL opcodes
5d680425db40 compiler: stop emitting I_MCALL/I_QMCALL opcodes
a616feed39eb compiler, vm: rework optional chaining and function call semantics
0946a4fb20b8 vm: adjust JMPNT opcode behavior
6f8291f73757 compiler: improve assignment lhs expression checks
cf846c4a11d4 vm: properly handle modulo by zero
4d81e6c13506 resolv: add documentation and fix clobbering ns strings
20ee2dabd243 debian/changelog: v0.0.20250529
50d303c8309d ubus: add support for automatically subscribing to objects
5a0d21d59f88 vm: export function for converting exception to ucode value
aaf712eb4fb4 uloop: add guard() function
693af2b61b52 ubus: add guard() function

Fixes: https://github.com/jow-/ucode/issues/307
Fixes: https://github.com/jow-/ucode/issues/313
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-18 12:22:25 +02:00
Felix Fietkau b626262226 ucode: update ubus/uloop exception handling patches
Function renames and a leak fix

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-14 12:16:50 +02:00
Felix Fietkau 77b9393d2f ucode: fix an issue in exception handling improvement for ubus/uloop
Remove an uloop_end() call from a user cb that wasn't there before

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-06 22:05:30 +02:00
Felix Fietkau 185b48e330 ucode: add patches to improve exception handling for ubus/uloop
Add API to allow setting an exception handler for user provided callbacks

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-05 14:41:00 +02:00
Felix Fietkau bbd95c0523 ucode: add ubus refcounting fix
Fixes a regression in the last ucode update

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-06-20 22:54:32 +02:00
Felix Fietkau 64570766cb ucode: update to Git HEAD (2025-06-09)
54b00e3b1fa9 ubus: fix double registry clear on disconnect
69521b55855c ubus: fix use-after-free on deferred request reply() method
22e8c16d9deb debug: fix crash when passing tagged string to getinfo()
2c9eea5174d6 ubus: use ucv_resource_create_ex for connections/channels
0a4cf4b7e71a ubus: use ucv_resource_create_ex for for ubus.request resources
99ee75a69cd3 ubus: use ucv_resource_create_ex for ubus.deferred resources
f085a42b977f ubus: use ucv_resource_create_ex for objects
94ad17d13a0d ubus: use ucv_resource_create_ex for ubus.notify resources
a3fa47fdda3e ubus: use ucv_resource_create_ex for ubus.listener resources
9ab5fa869dec ubus: use ucv_resource_create_ex for ubus.subscriber resources
be92ebd70633 CI: debian: install cmake package
fd202fd40bd1 socket: respect port argument in sockinst.connect()
767c209b917b socket: properly handle async `connect(2)` errors in socket.connect()
37ac8f112af6 socket: improve port argument validation in sockinst.connect()

Fixes: https://github.com/jow-/ucode/issues/302
Fixes: https://github.com/jow-/ucode/issues/303
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-06-13 10:16:06 +02:00
Felix Fietkau 87bfde67f2 ucode: ubus: fix use-after-free on deferred request reply() method
Hold a reference to the defer resource as long as it is still needed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-05-12 12:47:20 +02:00
Felix Fietkau 2a9316fbfb ucode: update to Git HEAD (2025-05-11)
567207a9bf16 fs: implement fileno() on directory handles
eb1d93235509 fs: support passing directory handle or fd in chdir()
38a2254337f1 build: detect whether toolchain employs default source fortification
6eddfc9dff17 resolv: fix fd leak in send_queries
3d36856b2dc5 uci: fix memory leak on cursor() error
aafde95f1ecf uci: add cursor() flags argument
d8cebc5a6bfd Revert "WIP: lib: support map() over objects"
2599cf80736b zlib: incorporate latest PR changes
830f316a7e49 socker: let sock.peercred() clear error on success
4cbac141406e types: rename u64_to_constant flag to ext_flag
d802fe5da5cd types: add support for resources with embedded data/values
71b4fdc6f60b types: add support for setting resource persistent flag
141f799eba08 uloop: use container_of instead of direct pointer casts
1396f8f2988d uloop: use uc_fn_thisval
9a121fc7440c uloop: drop object_registry
11b804d97086 socket: do not clear last_error in socket.error()
d5b3a9dc1091 socket: add strerror() method

Fixes: https://github.com/jow-/ucode/issues/285
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-05-11 15:26:08 +02:00
Felix Fietkau eaab68be92 ucode: add fix for double registry clear on channel disconnect
Avoid clobbering registry items of unrelated connections.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-05-09 12:05:11 +02:00
Felix Fietkau 2ced0e59a4 ucode: update to Git HEAD (2025-03-24)
2824982da336 ubus: fix broken uc_ubus_defer()

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-03-25 11:07:24 +01:00
Felix Fietkau 960e1c4c24 ucode: update to Git HEAD (2025-03-17)
9d94d54ed1a3 uci: implement cursor.list_append() and cursor.list_remove()
a5a299075f37 zlib: rework code logic
ee6a6c3ca579 zlib: deduplicate code
d20f7bb87d47 zlib: add stream-oriented deflate operations
0255af462be3 zlib: add stream-oriented inflate operations
9260bd5354bf WIP: lib: support map() over objects
60f05ac60bfe docs: cover switch statement in syntax article
338aa2ebf00e docs: add article with array specific information
df5a79a04b17 uci: link save() and commit() functions in cursor class description
03fb60d0e4b3 docs: add detailed documentation article for dictionaries
8e122f16327c ubus: add support for calling system objects
21a615c84367 socket: add reuseaddr argument for socket.listen()
e04908ef57e7 uci: add support for altering the override config directory
9dbace122d7e socket: add missing documentation for socket.listen() reuseaddr
312b25482b30 ubus: add errval_return() helper macro
1af4a6bbc206 ubus: add channel defer() method
0002684b9772 ubus: support sending multiple reply messages on a request
fb1da7157d13 ubus: remove broken implied await when calling defer() outside of uloop.run()
67a4ad20f172 ubus: fix uninitialized variable warning

Fixes: https://github.com/jow-/ucode/issues/279
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-03-17 10:25:23 +01:00
Felix Fietkau 0e672e9806 ucode: update to Git HEAD (2025-02-10)
a362263595e6 vm: fix inverted condition in uc_vm_signal_handlers_setup()
1b8660d33fb7 tests: adjust testcases after previous commit
4efad5388184 main: fix crash on printing -p output
0b80ceb29311 vm: close signal pipe in uc_vm_signal_handlers_reset()
175686c97d82 uci: eliminate usage of global variables
0f69da9c3777 struct: fix memory leak in buffer.pull()
47f3a6b69908 debian/control: Build-Depend on cmake
01efa7b92100 debian/control: Fix Standards-Version, add Bugs
f50149d67fef debian/source/format: change to native
bd001ae4f830 debian/control: libucode Recommends ucode-modules
87776a0bc2b2 docs: Mention `libmd` in macOS docs
826a5c9de7d3 docs: Fix compilation command for macOS
1fa771fc91c0 debian/copyright: fix missing dot to separate paragraphs
60c0e5eae992 debian/control: pkg-config now called pkgconf
244570db4f8e debian/changelog: switch versioning to native package scheme
fa2326fc00a0 .gitignore: ignore files generated by debuild
faec62367524 debian: ignore lintian warning no-manual-page
af881af4b0dc main: add global SCRIPT_NAME variable
5cbd32514187 socket: fix AF_PACKET recvmsg() and sockaddr formatting
6f71a35c4cfa rtnl: properly handle runtime exceptions in listener callback
6dd08716205f ci: bump actions/upload-artifact to v4
001ced17982f socket: properly support SO_ATTACH_FILTER sockopt
f0e865fe3ddd ubus: add named parameter support in functions with many params
18a2ffaf51fa fs: ioctl: export constants for direction values
0ba75bea925d fs: ioctl: improve ioctl read to avoid allocating twice
9da8b8aa4ad0 ubus: add defer.await() method
17dbf0bef4b6 ubus: add request get_fd/set_fd methods
4acb960c90f7 ubus: add support for sending file descriptors via ubus.call/defer
22b9523565a5 ubus: add support for receiving file descriptors in call and defer
c0d1654a450b ubus: add support for channels
b32321beb112 vm: fix crash due to stale frame pointer

Fixes: https://github.com/jow-/ucode/issues/254
Fixes: https://github.com/jow-/ucode/issues/255
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-02-10 17:02:20 +01:00
Robert Marko af6f1a90bb ucode: update to Git HEAD (2024-12-06)
47b54cf5a4b6 types: introduce `ucv_array_sort_r()` and `ucv_object_sort_r()`
efeb57806552 types, vm: refactor usage of global variables
f9d2faf67de6 vm: reset signals when freeing VM
4e86847d802d lib: utilize `ucv_array_sort_r()` and `ucv_object_sort_r()`
c71444ea301f types: ucv_resource_create(): rename `typename` parameter to `type`
373df7299c79 nl80211: properly support split_wiphy_dump for single phys
9bcd25f54708 lexer: Preserve keyword, regexp flags until processing non-comment tokens
0a7ff4715cb8 main: pretty-print `-p` output by default
4c3d5b469156 struct: Add new buffer API for incremental packing/unpacking
efc4122124cb struct: do not use global variables for caching types

Fixes: https://github.com/jow-/ucode/issues/248
Fixes: https://github.com/jow-/ucode/issues/250
Fixes: https://github.com/efahl/owut/issues/25
Link: https://github.com/openwrt/openwrt/pull/17191
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-12-06 19:26:47 +01:00
John Crispin ba9cdbeea8 ucode: update to latest HEAD
b0b5d93 Merge pull request #234 from IdWV/fs
60e7a88 Merge pull request #232 from sebastianertz/lib-digest
1752779 digest: implement compile time option to exclude less common algorithms
c7268a1 ci: include libmd in MacOS CI builds
fcb6f70 lib: introduce digest library
1323a27 Merge pull request #246 from jow-/fix-upvalue-resolve
ed5ce8f types: resolve upvalue values in arrays and objects
a6e0641 vm: resolve upvalues before pushing them onto the stack
ef1baab ci: drop OpenWrt tests for now
63e18ea fs: eliminate the usage of global variables
b1bd7b5 types: add ucv_resource_create() helper
3408edf Merge pull request #244 from nbd168/nl80211
8af77e7 nl80211: add new attributes for multi-radio support
1423ad7 nl80211: cover extended feature and EHT rate info attributes
ee1d6d8 Merge pull request #237 from sebastianertz/math
4b18a9b Merge pull request #213 from jow-/improve-vector-macros
1f022c0 math: removed global variable for thread safety
e5fe6b1 treewide: refactor vector usage code
20307ee utils: improve vector utilities
aa18952 Merge pull request #241 from jow-/socket-local-fanout-decl
79ccd9c socket: provide local definition of `struct fanout_args`
402280d Merge pull request #239 from jow-/safe-insert-during-obj-iteration
07afe96 Merge pull request #240 from jow-/stricter-number-conversion
736d450 types: fix potential use after free on adding keys during iteration
4134e71 vallist: more thoroughly check for trailing garbage after numeric string
9cf53dd Merge pull request #226 from jow-/lexer-improvements
2b2e732 lexer: make api functions public
855854f lexer: emit comment and template statement block tokens
328a50f lexer: improve token position reporting
fa22732 Merge pull request #225 from jow-/compiler-fix-keyword-property-labels-after-spread
6e88c62 Merge pull request #224 from jow-/lib-fs-readline-leak
94d1211 compiler: properly treat property names after spread expressions
67cd123 fs: fix potential memory leak on i/o errors in .read()

Signed-off-by: John Crispin <john@phrozen.org>
2024-12-02 13:55:36 +01:00
Felix Fietkau 5db27664bc ucode: add support for nl80211 vif radio mask
Used for multi-radio support

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-10-22 14:40:43 +02:00
John Crispin 92e6b84d15 ucode: update to latest HEAD
b610860 Merge pull request #223 from jow-/nl80211-add-eht-attributes
4e0456b nl80211: add EHT mac/phy capabilities
c938ee9 Merge pull request #218 from jonasjelonek/add-ioctl
56ebeec fs: add ioctl() file method
d0f423b Merge pull request #221 from mikma/fix-getenv
86f1121 lib: test if call to getenv() destroys environ
7af80d9 lib: use copy of environ pointer in getenv()
6ea37c8 ci: bump upload-artifact to v3
26d7292 Merge pull request #214 from jow-/ucode-test-runner
fbabec4 tests: replace test runner shell script with ucode implementation
e391ef5 main: prevent invalid memory access when executing empty stdin
b391fd7 Merge pull request #211 from jow-/hwsim-support
bc13278 nl80211: support the MAC80211_HWSIM netlink protocol family
f5b5a58 nl80211: drop unused structure members from connection context
f6ea6fc nl80211: support conversion from/to struct array attributes
115a84f nl80211: gracefully handle illegal netlink error code

Signed-off-by: John Crispin <john@phrozen.org>
2024-10-02 15:12:18 +02:00
Felix Fietkau 2ee1392e09 ucode: another fix for host installation
The previous host installation fix accidentally moved the rpath settings
out of CMAKE_HOST_OPTIONS and into CMAKE_OPTIONS.

Fixes: ae42ecaad4 ("ucode: fix host installation")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-09-20 11:47:00 +02:00
David Bauer 9d663c7435 ucode: fix missing backslash
Fixes: ae42ecaad4 ("ucode: fix host installation")

Signed-off-by: David Bauer <mail@david-bauer.net>
2024-09-15 03:30:06 +02:00
David Bauer ae42ecaad4 ucode: fix host installation
The path for linking libucode.so was not specified for the ucode binary.
This breaks execution of ucode in the host context.

Signed-off-by: David Bauer <david.bauer@uniberg.com>
2024-09-11 00:37:34 +02:00