Age | Commit message (Collapse) | Author |
|
For certain operations, such as bringing up interfaces, it is required to
initialize the ifi_change mask in the ifinfomsg struct.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
rtnl: update NETLINK_GET_STRICT_CHK socket flag with every request
|
|
compiler: fix stack mismatch on nonmatching switch statements with lo…
|
|
nl80211: fix NL80211_SURVEY_INFO_NOISE datatype
|
|
So far the NETLINK_GET_STRICT_CHK socket flag was only set on the implicit
socket creation performed during the first request and ignored for
subsequent ones which made it impossible to perform only some requests
with enabled strict checking.
Modify the logic to check the flag state for every request and change
it if needed. This allows performing both strict and non-strict requests
over the same connection.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Report the noise value as signed integer to calling ucode.
Reported-by: John Crispin <john@phrozen.org>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When a switch statement containing cases with local variable declarations
and no default case is evalulated and none of the the cases matched, the
local variable slots were never initialized but got popped off the stack
when execution resumed after the switch scope, leading to a mismatch in
stack layout between compiler and runtime, causing local variables to
yield wrong values or a stack underflow triggering a segmentation fault.
Solve this issue by patching the last conditional case match jump to hop
beyond the local variable pop instructions when no default case is defined.
Also extend the regression test case dealing with other switch related
stack mismatch issues to cover this particular problem as well.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
nl80211: recognize further NL80211_STA_INFO_* NLAs
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
struct: add optional offset argument to `unpack()`
|
|
Extend the `unpack()` function to take an optional, second offset parameter
which is useful to skip an initial portion of the input data without having
to encode pad bytes into the format string.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
rtnl: fix segmentation fault on parsing linkinfo RTA without data
|
|
rtnl: zero request message headers
|
|
rtnl: fix premature netlink reply receive abort
|
|
Some link types, such as veth, yield an IFLA_LINKINFO nla without an
embedded IFLA_INFO_DATA / INFLA_INFO_SLAVE_DATA nla which causes the
nla converter to dereference a NULL nla pointer.
Properly deal with such cases and check for the existence of the
child nla before attempting to parse it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
rtnl: avoid stray "netlink: %d bytes leftover after parsing attributes."
|
|
struct: fix packing `*` format after other repeated formats
|
|
For route netlink request messages having a header struct, uc_nl_request()
invokes nlmsg_reserve() to reserve room for the struct data but the
nlmsg_reserve() function only zeroes additional alignment bytes, not the
actual reserved buffer space.
Extend the existing logic to explicitly zero out the reserved header space
in order to avoid sending uninitialized struct member values to the kernel.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The nl_recvmsgs() logic in uc_nl_request() incorrectly stopped reading
the socket before the netlink ACK message was handled for non-multipart
replies.
This caused subsequent requests to incorrectly receive the ACK of the
previous request, leading to a failure to receive the actual reply.
Fix this issue by continue reading the socket until either the finish
callback for multipart (dump) messages or the ack callback for non-
multipart messages was received.
This fix is basically the same as the one applied to the nl80211 module
in 54ef6c0 ("nl80211: fix premature netlink reply receive abort").
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some nested RTAs such as IFLA_INET_CONF do not contain actual sub-RTAs but
just an array of integers. Avoid calling a no-op `nla_parse()` for such
attributes to suppress the non-harmful leftover bytes warning emitted by
libnl.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When packing a format such as `!6C*`, the `*` format was not included into
the result buffer due to improper tracking of the function argument offset.
Solve this issue by taking field repetitions into account when tracking
the argument offset while calculating the size of dynamic arguments.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Number literals
|
|
- Recognize new number literal prefixes `0o` and `0O` for octal as well
as `0b` and `0B` for binary number literals
- Treat number literals with leading zeros as octal while parsing but
as decimal ones on implicit number conversions, means `012` will yield
`10` while `+"012"` or `"012" + 0` will yield `12`
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
For string cases, turn `int()` into a thin `strtoll()` wrapper which
attempts to parse the initial portion of the string as a decimal integer
literal, optionally preceded by white space and a sign character.
Also introduce an optional `base` argument for string cases while we're
at it and adjust the existing stdlib test case accordingly.
The function now behaves mostly the same as ECMAScript `parseInt(val, 10)`
for string cases, means it will recognize `012` as `12` and not `10` and
it will accept trailing non-digit characters after the initial portition
of the input string.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
ci: make jobs faster during pull request testing
|
|
lib: rework uc_index() implementation
|
|
- Fix segfault on passing string haystack with non-string needle argument
- Perform strict equality tests against array haystacks
- Make string searches binary safe
- Improve left index string search performance
- Improve right index array search performance
- Add missing test coverage for index() and rindex()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When compiling expressions followed by a unary operator, the compiler
triggered a segmentation fault due to invoking an unset infix parser
routine.
Explicitly handle this case and raise a syntax error if such an
invalid expression is encountered.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
If the read limit passed to fs.readfile() is smaller than BUFSIZ then
disable stdio input buffering to avoid overreading the underlying file.
This is useful when reading small amounts of data from special files
such as /dev/urandom, where a readfile call limited to 16 bytes might
actually read 4096 due to stdio buffering.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: introduce hexenc() and hexdec()
|
|
Add two new functions to deal with encoding and decoding of hexadecimal
digit strings:
- hexenc() - convert the given input value into a lower case hex digit
string, implicitely converting the input argument to a string value
if needed
- hexdec() - decode the given input hex digit string into a byte string,
skipping whitespace or optionally specified characters in the input
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
With the proliferation of test cases, CI runs tend to become rather long
since we run all tests under valgrind using multiple gcc and Clang
versions each.
In order to speedup the jobs, we tests pull requests under the most
recent Clang versions and run all tests when the code hits the master
branch.
Closes #66
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
syntax: implement support for ES6 template literals
|
|
Implement support for ECMAScript 6 template literals which allow simple
interpolation of variable values into strings without resorting to
`sprintf()` or manual string concatenation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
vm: stop executing bytecode on return of nested calls
|
|
When a managed function is indirectly invoked during bytecode execution,
e.g. when calling the tostring() method of an object prototype during
string concatenation, the invoked function must stop executing bytecode
upon return to hand control back to caller.
Extend `uc_vm_execute_chunk()` to track the amount of nested function
calls it performs and hand back control to the caller once the toplevel
callframe returns. Also bubble unhandled exceptions only as far as up
to the original caller.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
treewide: move json-c compat shims into internal header file
|
|
Do not expose the json-c compat functions in ucode's public headers to
avoid clashes when building on systems with modern json-c.
Also remove some explicit json-c/json-c.h includes in places where it is
not needed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
lib: let `json()` accept input objects implementing `read()` method
|
|
Move the invocation of the unhandled exception callback handler out of
`uc_vm_execute_chunk()` into both `uc_vm_execute()` and `uc_vm_invoke()`
in order to consistently report exceptions exactly once regardless of
whether a native or managed code function is executed as topmost VM
call.
This solves cases where the unhandled exception callback was either
called multiple times or never at all.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When invoking a native function as toplevel VM call which indirectly
triggers an unhandled exception in managed code, the callframes are
completely reset before the C function returns, leading to invalid
memory accesses when `uc_vm_call_native()` subsequently popped it's
own callframe again.
This issue did not surface by executing script code through the
interpreter since in this case the VM will always execute a managed
code as toplevel call, but it could be triggered by invoking a native
function triggering an exception through the C API using `uc_vm_call()`
on a fresh `uc_vm_t` context or by utilizing the CLI interpreters `-l`
flag to preload a native code library triggering an exception.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Do not continue loading other libraries or executing the main code if
loading one of the preload libraries fails.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
fs: implement `fs.readfile()` and `fs.writefile()`
|
|
Extend the `uc_json()` implementation to accept readable objects in
addition to plain input strings. This allows parsing JSON input directly
from open file handles, sockets or other kinds of producer objects without
the need to store the entire JSON source string intermediately in memory.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The `fs.readfile()` and `fs.writefile()` functions allow efficient reading
and writing of whole files, reducing the required boilerplace code compared
to using the `open()`/`read()`/`write()`/`close()` API.
- `fs.readfile()` takes two arguments; the path to open and an optional
limit value. If limit is omitted, `null` or negative, the entire file
contents are read, otherwise the specified amount of bytes. Returns the
read file contents as string or `null` on error.
- `fs.writefile()` takes three arguments; the path to open/create, the
contents to write and an optional limit value. If limit is omitted, the
entire content is written, otherwise just the specified amount of bytes.
Non-string content arguments are internally converted to strings, `null`
is treated as empty string. Returns the amount of bytes written or `null`
on error.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: dfaf05a ("ci: debian: automatically update changelog from Git tag")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|