summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2024-10-17socket: provide local definition of `struct fanout_args`Jo-Philipp Wich
The `fanout_args` structure is a relatively recent addition to the kernel so provide a local definition for it, like we already do it for other like `timeval_old`. Fixes: #217 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-10-17Merge pull request #239 from jow-/safe-insert-during-obj-iterationJo-Philipp Wich
types: fix potential use after free on adding keys during iteration
2024-10-17Merge pull request #240 from jow-/stricter-number-conversionJo-Philipp Wich
vallist: more thoroughly check for trailing garbage after numeric string
2024-10-17types: fix potential use after free on adding keys during iterationJo-Philipp Wich
When keys are added to the object currently being iterated by a for loop, the insert operation might cause a hashtable resize with a subsequent memory reallocation and a different table base pointer, clobbering the entry pointers held by iterators pointing to the containing object of the resized table. In order to address this issue while keeping the iteration overhead low, extend the object key insert logic to check whether the insertion will trigger a reallocation and backup and restore the iterator pointers when needed. This slightly increases the size of the iterator states but the overhead for this should be neglectible as there'll only be a low amount of concurrently active iterations at any time. Fixes: #230 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-10-16vallist: more thoroughly check for trailing garbage after numeric stringJo-Philipp Wich
When converting numeric strings into numbers, ensure that only optional trailing whitespace follows and no other characters. Fixes: #231 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-24Merge pull request #226 from jow-/lexer-improvementsJo-Philipp Wich
Enhance lexer functionality and improve token reporting
2024-09-23lexer: make api functions publicJo-Philipp Wich
Make the lexer API functions `uc_lexer_init()`, `us_lexer_free()` and `uc_lexer_next_token()` public for use in loadable extensions. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-23lexer: emit comment and template statement block tokensJo-Philipp Wich
Tweak the token stream reported by the lexer in order to make it more useful for alternative, non-compilation downstream parse processes such as code intelligence gathering within a language server implementation. - Instead of silently discarding source code comments in the lexing phase, emit TK_COMMENT tokens which is useful to e.g. parse type annotations and other structured information. - Do not silently discard TK_LSTM tokens but report them to downstream parsers instead. - Do not silently emit TK_RSTM tokens as TK_SCOL but report them as-is to downstrem parsers. - Adjust the byte code compiler to properly deal with the changed token reporting by discarding incoming TK_COMMENT and TK_LSTM tokens and by remapping read TK_RSTM tokens to the TK_SCOL type. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-23lexer: improve token position reportingJo-Philipp Wich
- Report end position for emitted tokens. This is required to reliably determine the token length, e.g. for downstream code intelligence use cases - Fix start offset of continued template literal string tokens. Previously the start offset of a literal string following a `${...}` placeholder expressions was shifted by one byte - Report proper start offset of `TK_LEXP` tokens. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-23Merge pull request #225 from ↵Jo-Philipp Wich
jow-/compiler-fix-keyword-property-labels-after-spread compiler: properly treat property names after spread expressions
2024-09-23Merge pull request #224 from jow-/lib-fs-readline-leakJo-Philipp Wich
fs: fix potential memory leak on i/o errors in .read()
2024-09-23compiler: properly treat property names after spread expressionsJo-Philipp Wich
Ensure that unquoted property names following spread expressions in object declaration literals are not treated as keywords. Prior to this fix, an expression such as `{ ...someobj, default: 1 }` would result in a compile time syntax error. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-23fs: fix potential memory leak on i/o errors in .read()Jo-Philipp Wich
Make sure to free the line buffer pointer when aborting a `getline()` / `getdelim()` based read operation on i/o errors. As an example, this issue could be triggered by receiving a broken pipe error while attempting to read a line from stdin. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-09-21Merge pull request #223 from jow-/nl80211-add-eht-attributesJo-Philipp Wich
nl80211: add EHT mac/phy capabilities
2024-09-21nl80211: add EHT mac/phy capabilitiesChad Monroe
Signed-off-by: Chad Monroe <chad@monroe.io>
2024-09-20Merge pull request #218 from jonasjelonek/add-ioctlJo-Philipp Wich
fs: add ioctl() file method
2024-09-20fs: add ioctl() file methodJonas Jelonek
implements ioctl() for a given file handle on Linux. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
2024-09-20Merge pull request #221 from mikma/fix-getenvJo-Philipp Wich
lib: use copy of environ pointer in getenv()
2024-09-20lib: test if call to getenv() destroys environMikael Magnusson
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
2024-09-20lib: use copy of environ pointer in getenv()Mikael Magnusson
Without this fix a call to getenv() without parameters destroys environ, and subsequent calls to getenv() (with or without parameter) return nothing. Fixes: #219 Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
2024-09-20ci: bump upload-artifact to v3Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-29Merge pull request #214 from jow-/ucode-test-runnerHEADmasterJo-Philipp Wich
tests: replace test runner shell script with ucode implementation
2024-07-29tests: replace test runner shell script with ucode implementationJo-Philipp Wich
The ucode interpreter and libraries are mature enough to execute their own testcases now, so replace the existing shell script with an equivalent ucode implementation. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-29main: prevent invalid memory access when executing empty stdinJo-Philipp Wich
In case the ucode cli executes stdin with zero bytes length, ensure to pass a dummy string instead of a NULL pointer to uc_source_new_buffer() to prevent libc's fmemopen() from writing to nonexistent memory. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-11Merge pull request #211 from jow-/hwsim-supportJo-Philipp Wich
Hwsim support
2024-07-11nl80211: support the MAC80211_HWSIM netlink protocol familyJo-Philipp Wich
The mac80211_hwsim module exposes a custom generic netlink family for managing simulated phys and userspace data frame transmission. Since hwsim functionality is closely related to nl80211 and useful to e.g. manage simulated wireless testbeds, I decided to include support directly into the nl80211 module. Example calls for creating and destroying hwsim wiphys: nl80211.request(nl80211.const.HWSIM_CMD_NEW_RADIO, 0, { perm_addr: "02:11:22:33:44:55", support_p2p_device: true }); nl80211.request(nl80211.const.HWSIM_CMD_DEL_RADIO, 0, { radio_name: "phy2" }); Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-11nl80211: drop unused structure members from connection contextJo-Philipp Wich
The `nlctrl` and `nl80211` family pointers were never used, so drop them from the connection context structure. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-11nl80211: support conversion from/to struct array attributesJo-Philipp Wich
Some netlink attributes, e.g. `HWSIM_ATTR_TX_INFO` contain arrays of structures. In order to cover this use-case, extend the ucode <-> nla conversion routines to support `DT_NESTED` declaration in conjunction with `DF_ARRAY`. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-11nl80211: gracefully handle illegal netlink error codeJo-Philipp Wich
Some generic netlink commands, e.g. `HWSIM_CMD_NEW_RADIO` might reply with a bogus netlink error message containing a positive error code, leading to an infinite loop in `uc_nl_request()`. Gracefully deal with such occurrences by remapping the error code to `NLE_RANGE` with a custom message. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-07-11Merge pull request #210 from nbd168/nl80211Jo-Philipp Wich
nl80211: add wiphy multi-radio support
2024-07-09nl80211: add wiphy multi-radio supportFelix Fietkau
Support new attributes that describe multiple radios belonging to a single wiphy. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-07-09nl80211: update nl80211.h to latest wireless-nextFelix Fietkau
Includes the new attributes for wiphy multi-radio support Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-07-07Merge pull request #208 from nbd168/nl80211Jo-Philipp Wich
2024-07-07nl80211: add support for multi-attribute arraysFelix Fietkau
For newly added attributes, the kernel prefers to no longer add a nesting container attribute. Instead, an attribute with the element type is simply added multiple times within the outer container. Add support for this array style, which will be used in the pending wiphy multi radio support. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-07-07nl80211: move access to tb array out of uc_nl_convert_attr and belowFelix Fietkau
Only one place needs access to another attribute from the tb array (HE MCS rates). In order to make that access possible, add a flag to indicate a second attribute dependency via auxdata. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-06-18Merge pull request #204 from f00b4r0/zlibJo-Philipp Wich
2024-06-18Merge pull request #206 from efahl/issue205Jo-Philipp Wich
2024-06-18lib: introduce zlib libraryThibaut VARÈNE
Introduce a new "zlib" library which provides simplified bindings for zlib inflate/deflate operations. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
2024-06-18Merge pull request #207 from nbd168/fsJo-Philipp Wich
Add fs module utility functions
2024-06-17fs: add lock() file methodFelix Fietkau
Implements file based locking on a given file handle. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-06-17fs: add truncate() file methodFelix Fietkau
Trunates the file referenced by a file handle Signed-off-by: Felix Fietkau <nbd@nbd.name>
2024-06-10core-lib: improved documentationEric Fahlgren
- document optional 'base' parameter on 'int' function - add description of 'fn' parameter call sequence to 'map' - add several usage examples to both 'int' and 'map' - reference similarity between 'map' and 'filter' use of 'fn' - fix a few typos Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-05-21Merge pull request #202 from jow-/socket-improvementsJo-Philipp Wich
Socket improvements
2024-05-21socket: implement recvmsg(), sendmsg() and cmsg supportJo-Philipp Wich
Implement socket.recvmsg(), socket.sendmsg() and support for encoding and decoding well known control message types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: add IPv6 socket optionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: handle further socket option value typesJo-Philipp Wich
- Handle varying integer sizes for socket option values - Support interfaces name and index option values Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: improve uc_socket_listen() behaviorJo-Philipp Wich
- Treat address string values containing slashes as AF_UNIX addresses - Default to SOCK_DGRAM for non AF_INET, AF_INET6 sockets - Gracefully handle EOPNOTSUPP condition after listen() call Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: improve uc_socket_connect() behaviorJo-Philipp Wich
Treat address strings containing slashes as AF_UNIX paths and do not attempt to resolve them. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: support IPv6 addresses in struct conversion routinesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2024-05-17socket: uv_to_sockaddr(): fix length calculation for AF_UNIX addressesJo-Philipp Wich
Do not attempt to calculate a dynamic length for AF_UNIX socket addresses but return the total size of `struct sockaddr_un`, like we do it for the structures of other address families as well. Fixes incorrect domain socket path truncation. Signed-off-by: Jo-Philipp Wich <jo@mein.io>