Security fixes, code modernization, and community PR integration#100
Conversation
## Security Fixes - Fix memory leak: piStartRef was not freed in cleanup paths - Add NULL checks after all malloc/calloc calls to prevent crashes - Add compiler security flags: -fstack-protector-strong, -D_FORTIFY_SOURCE=2, -Wformat-security ## Code Modernization - Modernize CMakeLists.txt with proper Release/Debug build separation - Use target-based CMake properties instead of global definitions - Add -Wpedantic flag (with exception for 3rdparty getopt code) - Update copyright years to 2015-2025 - Update libmodbus minimum version to 3.1.7 - Translate all French comments to English ## Community PR Integration - Implement PR epsilonrt#87: Check modbus_set_slave() return value to prevent crashes with invalid slave addresses (credit: @r00t-) - Implement PR epsilonrt#90: Add -x option to print register addresses in hexadecimal format (credit: @ciakval) - Implement PR epsilonrt#99: Add -Q and -X options for libmodbus quirks (MAX_SLAVE and REPLY_TO_BROADCAST) (credit: @JesseRiemens) ## New Features - `-x` Print address (reference) in hexadecimal format - `-Q` Enable MAX_SLAVE quirk (accept slave id 0-255) - `-X` Enable REPLY_TO_BROADCAST quirk (send reply to broadcast) ## CI/CD - Add GitHub Actions workflow for automated builds on Linux, macOS, and Windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR consolidates security hardening and modernization work for mbpoll, including safer memory allocation handling, new CLI features, updated build tooling (CMake), and a new multi-platform GitHub Actions CI workflow.
Changes:
- Replace
assert()-based allocation checks with explicit NULL checks and improve cleanup paths. - Add new CLI options
-x,-Q, and-X(hex address printing + libmodbus quirks support), plus corresponding help/README updates. - Modernize
CMakeLists.txt(target-based flags, Release/Debug separation, updated libmodbus minimum) and add CI builds for Linux/macOS/Windows.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/mbpoll.c |
Adds new CLI flags, enables libmodbus quirks, improves allocation failure handling, and fixes a cleanup leak. |
CMakeLists.txt |
Modernizes build configuration, hardening flags, dependency discovery, and libmodbus minimum version. |
.github/workflows/ci.yml |
Adds CI jobs for Linux/macOS/Windows builds and basic smoke checks. |
README.md |
Updates libmodbus minimum version and documents new CLI options. |
mbpoll-config.h |
Updates copyright year. |
src/serial.h |
Translates comments to English and updates copyright year. |
src/serial.c |
Updates copyright year. |
src/custom-rts.h |
Updates copyright year. |
src/custom-rts.c |
Updates copyright year. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Bump CMake minimum to 3.13 (required for target_link_directories) - Move find_package(PkgConfig) to Unix-only block (Windows uses bundled libmodbus) - Fix printf format UB: cast iAddr to unsigned int for %X specifier - Allow RTU slave address 0 when -Q quirk is enabled - Apply consistent quirk logic to TCP mode for symmetry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
so people are now using "AI" bots for stealing other people's contributions from open merge requests and claiming ownership of them? |
I found your Pr useful and worth adding. Where do you see me claiming your contribution as my own? As far as I can tell, you and your Pr are both tagged. |
Could have cherry-picked and included the contributions itself - then the code authored by us is merged. I don't think you had bad intentions necessarily, but I feel @r00t- s annoyance as well. |
|
You're right, and I owe you all an apology. I should have cherry-picked your commits instead of reimplementing the functionality. Mentioning your PRs in the description doesn't replace proper git authorship — your names belong in If @epsilonrt is open to it, I'd like to fix this properly: revert the portions of this PR that overlap with #87, #90, and #99, then cherry-pick your original commits so you get the authorship credit you deserve. Happy to put together that follow-up PR if the maintainer agrees. Again, apologies for the misstep. |
Summary
This PR consolidates security fixes, code modernization, and integrates several valuable community PRs that have been pending.
Security Fixes
piStartRefwas not freed invSigIntHandler()andvFailureExit()cleanup pathsmalloc/calloccalls instead of relying onassert()(which is disabled byNDEBUGin release builds)-fstack-protector-strong,-D_FORTIFY_SOURCE=2,-Wformat-securityfor release buildsCode Modernization
NDEBUGis now only defined in Release builds; Debug builds have-g -O0for proper debugging-Wpedanticwith exception for 3rdparty getopt code (uses deprecatedregisterkeyword)Community PR Integration
This PR implements the functionality from the following open PRs:
modbus_set_slave()return value to prevent crashes with invalid slave addresses-xoption to print register addresses in hexadecimal format-Qand-Xoptions for libmodbus quirks (MAX_SLAVE and REPLY_TO_BROADCAST)New Command-Line Options
CI/CD
Test Plan
-xoption displays hex addresses correctly-Qoption allows slave addresses 0-255-Xoption for broadcast replyBreaking Changes
modbus_enable_quirks()function)🤖 Generated with Claude Code