Update the fragmented data transport parsing to always consume complete
control messages, regardless of any validation errors. Simplify the
implementation of this by defining the packets as packed structures.
Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit fixes the bug by ensuring `to_write` is properly bounded.
It is now calculated as the minimum of the remaining requested bytes
(`nbytes - written`) and the remaining space in the current block
(`block_size - block_off`).
Fixes#106276
Signed-off-by: Ashirwad Paswan <ashi06712@gmail.com>
Replace the hardcoded WAMP RPC type values used when encoding OCPP
messages with their corresponding symbolic constants.
- Replace '2' with OCP_WAMP_RPC_REQ
- replace '3' with OCP_WAMP_RPC_RESP
This removes magic numbers and improves human readability.
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Static analysis has a difficult time tracing whether a call to
ocpp_send_to_server() needs to initialize sndlock and rspsig because
the message type is set very much earlier in the program logic flow.
Note that coverity is creating a single issue for sndlock and for rspsig
in each function that calls ocpp_send_to_server() without initializing
them.
Adding a NULL test will prevent future static analysis false positives.
Fixes#100026Fixes#100025Fixes#100024Fixes#100017Fixes#100015Fixes#100013Fixes#100011Fixes#100010Fixes#100008Fixes#100006
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Drop the unnecessary _ri_ptr NULL check, as multi-instance resources
always provide a valid instance array when _ri_count > 0. This
simplifies the initialization logic and prevents compile time warrning
messages/noice.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>
ethernet_update_tx_stats checks the multicast address first and then the
broadcast which causes the broadcast address to be treated as multicast
and not counted correctly.Fix this by checking broadcast address first,
followed by the multicast address.
Signed-off-by: Taha Benderli <taha.benderli@analog.com>
There are several areas in the networking stack where this is missing.
So make sure we add it.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
`net_calc_chksum` is designed to return uint16_t checksum.
Its current behavior is to return 0 checksum on error
(or on an empty payload) and a valid non zero checksum for non empty
payloads. 0 could be a valid checksum for empty payload.
So update the `net_calc_chksum` and its wrapper's definition to
return error codes.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
tcp_options_len calculation in tcp_data_len can underflow
if th_off(th) is less than 5. This can lead to a huge
tcp_options_len value and subsequently a wrong data length calculation.
Add the checks in tcp_recv() which is a top API, so that the checks
are covered at the entry point.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106657
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Add an initialisation time check for stream flash that the requested
offset and size does not overflow `size_t`. This in turn ensures that
`inspect_device` doesn't erroneously return `0` if the addition would
have overflowed.
Signed-off-by: Jordan Yates <jordan@embeint.com>
NRPA should be rotated every TGAP(private_addr_int)
according to spec, which is also checked in PTS.
Signed-off-by: Artur Dobrynin <artur.dobrynin@nordicsemi.no>
Introduce the CONNMON_LINK_UTILIZATION resource to the Connection
Monitoring object. Add backing storage, initialize it during instance
creation, and register it in the resource table.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Remove unused code related to zbus_proxy_agent_backend_desc and run-time
backend registration left over from early development.
Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Select the interface whose on-link prefix has the greatest length when
multiple prefixes match the same address. Fixes wrong iface selection
when a host has several interfaces whose on-link prefixes overlap (e.g.
a shorter prefix on one link and a longer, more specific prefix on
another). Callers that pass iface == NULL still get a boolean only; no
interface pointer is written.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
The support for running network TX/RX threads in pre-emptive way
was introduce in 2020. The experimental status is no longer valid
as the feature has been there for quite some time and it is being tested
also regularly by CI.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When the SenderResponseTimer expires in PE_DRS_SEND_SWAP, PE was
unconditionally transitioning to PE_SNK_READY. This is incorrect when
the port is operating as a Source, as it should return to PE_SRC_READY.
Replace pe_set_state(dev, PE_SNK_READY) with pe_set_ready_state(dev),
which selects the correct ready state based on the current power role.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
The transition from Attached.SNK to Unattached.SNK is currently
triggered if vbus is < vSafe5V.
USB-Type C Spec R2.4 Table 4-3 defines vSinkDisconnect as
the voltage to be used for the transition from
Attached.SNK to Unattached.SNK
This commit changes the check to use the correct voltage level.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
Callback for IBI (In-Band Interrupt) was being set after enabling IBI -
which could be an issue if an IBI would be asserted in between enabling
IBI and setting the callback. This patch simply sets the callback before
enabling IBI.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Add a `mctp_i2c_gpio_target_unregister`, which basically calls I2C
`i2c_target_unregister`. While libmctp binds are only "started", with
no cleanup, this will be useful for tests, allowing a sequence of them.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
When sending "big messages", libmctp queues a series of packets and
calls the binding in a loop to transmit all messages. If previous
message was still being sent, transmission would fail with -EBUSY, but
libmctp wouldn't handle it.
This patch makes the UART TX blocking, so it only returns after
completion, allowing next TX to just work.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Enabling CONFIG_XOSHIRO_RANDOM_GENERATOR when
CONFIG_ENTROPY_NEEDS_POST_PROCESSING is set, we can support entropy
drivers which are not able to provide large amount of data.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
The functions that add DNS records (PTR, SRV, TXT, AAAA, A) all use a
buf_size argument which represents the size of the whole buffer, not the
remaining size. The higher function that calls these did not provide the
correct argument: it passed the remaining size in the buffer.
Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
Stop scheduling bt_id_add() as workqueue work during settings load.
Mark keys BT_KEYS_ID_PENDING_ADD only, then flush them synchronously
in start_scan(), adv_start_legacy()/bt_le_ext_adv_start(),
bt_conn_le_create and bt_conn_le_create_auto when
BT_DEV_ID_PENDING is set.
We don't necessarily need to update resolving list in controller
unless actively start using it, also eliminates a race where a
workqueue-issued bt_id_add() blocks on HCI while bt_keys_clear()
concurrently zeroes the same key slot.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
The DHCPv4 client logs the received address with NET_INFO when an
address is successfully obtained from the server. The DHCPv6 client
had no equivalent log message, making it difficult to confirm that
DHCPv6 address assignment succeeded.
Add a NET_INFO log when a DHCPv6 address is successfully configured,
consistent with the DHCPv4 client behavior.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
In setup_ipv6(), the net management event callback registration was
placed after the early exit for empty CONFIG_NET_CONFIG_MY_IPV6_ADDR.
This means that in DHCPv6-only configurations (no static IPv6 address),
the callback was never registered, and the IPv6 address and lifetime
were never printed when DHCPv6 obtained an address.
This is inconsistent with setup_ipv4(), which correctly registers the
callback before the empty address check, allowing DHCPv4 address
events to be handled even without a static IPv4 address.
Move the event callback registration and router flag check before the
empty address goto, and always include NET_EVENT_IPV6_ADDR_ADD in the
event mask so that DHCPv6 address additions are always captured.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
In net_context_get(), contexts[i].local is memset to zero before
find_available_port() is called. This leaves sa_family as 0, which
causes check_used_port() to skip both the IPv6 (sa_family ==
NET_AF_INET6) and IPv4 (sa_family == NET_AF_INET) collision-detection
branches, unconditionally returning "port available".
When the PRNG produces the same random port for two consecutive
socket() calls, the collision is not detected and both contexts are
assigned the same ephemeral port. The duplicate is only caught later
during listen() → net_conn_register(), which finds the identical
connection handler and returns -EADDRINUSE (errno 112).
Fix by setting sin6_family / sin_family on the local address
immediately after the memset and before find_available_port() is
called, so that check_used_port() enters the correct address-family
branch and properly detects port collisions.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
The exthdr_len was previously validated against the total
packet length, which did not account for the header's offset.
This could allow a crafted packet to cause an out-of-bounds
read by claiming a length that exceeds the remaining buffer.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106331
This commit:
1. Validates exthdr_len against (pkt_len - start_offset).
2. Adds strict bounds checking for sub-options (PADN/others)
to ensure they do not exceed the extension header boundary.
3. Validates the return value of net_pkt_skip().
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
On PD capable SRC detach, DPM was not being notified of
POWER_CHANGE_0A0 or NOT_PD_CONNECTED. Fix by notifying
POWER_CHANGE_0A0 in tc_attached_snk_exit() and NOT_PD_CONNECTED in
pe_suspend_entry().
On PD capable SNK or SRC detach, pe_suspend_entry() did not clear
the explicit contract flag. Fix by clearing PE_FLAGS_EXPLICIT_CONTRACT
in pe_suspend_entry().
On PD capable SNK attach, DPM was not being notified of PD_CONNECTED
at the correct time. Fix by notifying PD_CONNECTED when PS_RDY is
successfully transmitted (source) or received (sink), using
atomic_test_and_set_bit() to prevent duplicate notifications during
renegotiations.
Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
validate the assumptions about buffers returned by alloc_buf() in the
LE CoC receive path.
if the returned buffer does not provide enough user_data space for the
internal segment counter, disconnect and drop the buffer instead of
reading or writing past the metadata area.
also document that alloc_buf() must return a buffer with at least
sizeof(uint16_t) bytes of user_data.
Signed-off-by: Oleh Konko <security@1seal.org>
By making `MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG` depend on that neither
`CTR_DRBG_CSPRNG_GENERATOR` nor `PSA_CSPRNG_GENERATOR` is enabled so if
they are we automatically fall back to `MBEDTLS_PSA_CRYPTO_LEGACY_RNG`.
This combination is problematic because we get in a scenario where
`psa_generate_random()` => `get_random_data()` => `sys_csrand_get()` =>
`psa_generate_random()`.
Resolves#105626.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Add an internal cache buffer in Intel's
adsp mtrace backend to mitigate log overwrite
issue when slot window is full.
Signed-off-by: Jun Lai <jun.lai@dolby.com>
Fixes an unused function warning when compiling with llvm, looks like
that does not fire with gcc for inline functions but it does for llvm,
tested with:
west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/cdc_acm --
-DTOOLCHAIN_VARIANT_COMPILER=llvm -DCONFIG_UART_LINE_CTRL=n
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fixes:
zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:635:19:
warning: unused function 'hid_dev_set_out_polling' [-Wunused-function]
zephyrproject/zephyr/subsys/usb/device_next/class/usbd_hid.c:665:19:
warning: unused function 'hid_dev_set_in_polling' [-Wunused-function]
When compiling with LLVM:
west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/hid-keyboard --
-DTOOLCHAIN_VARIANT_COMPILER=llvm
Functions are only used when CONFIG_USBD_HID_SET_POLLING_PERIOD is
enabled, set as __maybe_unused instaed of inline.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Power managed devices should be able to return -EBUSY at
pm_action() (driver) calls without generating error log messages.
Suppress such error messages to allow the driver to decide at
sleep time if it still is unable to suspend, without generating
log noise.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
UVC counts frame intervals as 100ns units, so to get a number in
nanosecond, the value from USB needs to be divided by either
(USEC_PER_SEC * 10) or (NSEC_PER_SEC / 100). A mix of the two
was used.
Signed-off-by: Josuah Demangeon <me@josuah.net>
When UVC is part of a multi-function device, baInterfaceNr(0) may point
to an incorrect interface number. Assign the actual streaming interface
number after the configuration descriptor is initialized.
This is follow-up on commit 8d7bb597fc
("usb: uvc: use uvc_device_ in API and add _enable()/_shutdown()").
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This is more prone to breaking than simply inheriting all include
directories from the tfpsacrypto library.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
When logging statically configured network SSID, use the Kconfig string
instead of a SSID buffer where it was copied to, as the latter is not
guarantee to be NULL terminated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case CONFIG_WIFI_CREDENTIALS_STATIC is used, verify the statically
configured SSID/password lengths to guarantee they don't exceed the
allowed SSID and password character limits and thus overflow credential
buffers.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
do net_if_set_link_addr() for
NET_REQUEST_ETHERNET_SET_MAC_ADDRESS
in ethernet_set_config(), that way drivers don't have
to do it themself.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>