Skip to content

Update libmodbus to address CVE-2022-0367#3

Merged
Ziink4 merged 133 commits intomasterfrom
okurtsev/update3.1.11
Sep 4, 2025
Merged

Update libmodbus to address CVE-2022-0367#3
Ziink4 merged 133 commits intomasterfrom
okurtsev/update3.1.11

Conversation

@okurtsev
Copy link

@okurtsev okurtsev commented Sep 1, 2025

Merge tag 'v3.1.11'

stephane and others added 30 commits April 5, 2020 23:09
When compiling with gcc and option -Wconversion it fixes the
warning message

  warning: conversion from ‘X’ {aka ‘x’} to ‘Y’ {aka ‘y’} may change value

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
There is a small typo in tests/bandwidth-client.c.

Should read `response` rather than `reponse`.
Add Embox RTOS to the list of supported OSes
)

While handling MODBUS_FC_WRITE_AND_READ_REGISTERS, both address offsets
must be checked, i.e. the read and the write address must be within the
mapping range.

At the moment, only the read address was considered, it looks like a
simple copy and paste error, so let's fix it.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Sorry for the two PRs, I did one then realized I should check the other
This native libmodbus error code is defined but not used.
stephane and others added 25 commits July 17, 2024 11:58
…tephane#665, stephane#694)

* Removes useless memcpy calls and no longer used swap32 and swap16 macros.
* Updated float encoding functions to consider endianess of 16-bit registers (fixes stephane#665)
* Deprecated modbus_get_float() and modbus_set_float() are implemented using cdab variants.
CID 416366: INTEGER_OVERFLOW found with Coverity Scan.
The modbus_reply function is designed to receive arguments
from modbus_receive. This patch avoid a wrong use of memcpy if
the user chooses to inject a bad length argument.

Thank you Nozomi Networks Labs Advisory for the report.
- rename internal *_prepare_response_tid to *_get_response_tid
- change signature, don't need req length anymore
- remove misleading modification of req_length
- check of req length before use in memcpy for mask write register

Related to df79a02
…ix test suite and setter functions.

This reverts commit 49af73d.
The default port number of Modbus is 502 but it requires privileges on
Linux.
Copy link
Collaborator

@Ziink4 Ziink4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you open a PR on NEUWeb with the updated submodule to make sure all CI tests are green ?

Copy link
Collaborator

@Ziink4 Ziink4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 /usr/bin/gcc-13 -DDLLBUILD -DHAVE_CONFIG_H -D_CRT_NONSTDC_NO_DEPRECATE=1 -D_CRT_SECURE_NO_DEPRECATE=1 -Dlibmodbus_EXPORTS -I/home/jenkins/workspace/NEUWeb_PR-904/build/external/libmodbus/src -I/home/jenkins/workspace/NEUWeb_PR-904/external/libmodbus/src -O3 -DNDEBUG -fPIC -MD -MT external/libmodbus/CMakeFiles/libmodbus.dir/src/modbus-tcp.c.o -MF external/libmodbus/CMakeFiles/libmodbus.dir/src/modbus-tcp.c.o.d -o external/libmodbus/CMakeFiles/libmodbus.dir/src/modbus-tcp.c.o -c /home/jenkins/workspace/NEUWeb_PR-904/external/libmodbus/src/modbus-tcp.c
 /home/jenkins/workspace/NEUWeb_PR-904/external/libmodbus/src/modbus-tcp.c: In function '_modbus_tcp_set_ipv4_options':
 /home/jenkins/workspace/NEUWeb_PR-904/external/libmodbus/src/modbus-tcp.c:266:14: error: 'IPTOS_LOWDELAY' undeclared (first use in this function)
   266 |     option = IPTOS_LOWDELAY;
       |              ^~~~~~~~~~~~~~
 /home/jenkins/workspace/NEUWeb_PR-904/external/libmodbus/src/modbus-tcp.c:266:14: note: each undeclared identifier is reported only once for each function it appears in

We might need to adjust our CMakeLists, I think that we blindly use the config.h.win32 template for both windows and Linux, and it seems that it disables some linux specific macros needed by this commit : stephane@ae6f327

The way to do this would be to generate a linux config.h using the autoconf instructions on their repo, and add it to our fork as a separate config.h.unix

… HAVE_NETINET_IP_H directly in modbus-tcp.c for Linux builds to force including <netinet/ip.h> which provides IPTOS_LOWDELAY definition
@Ziink4 Ziink4 merged commit e285726 into master Sep 4, 2025
1 check passed
@Ziink4 Ziink4 deleted the okurtsev/update3.1.11 branch September 4, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.