Repository navigation
Changed "(char *)&mac_dest" to "mac_dest.c_str()" in setMacDest() to … - #17
Conversation
…fix MAC Address DLL Filter.
k3it
left a comment
There was a problem hiding this comment.
Approving — this is a correct, minimal fix for genuine undefined behavior.
mac_dest is a std::string, so (char *)&mac_dest passed the address of the string object into sscanf, causing it to parse the string's internal control structure rather than the text. That it worked on some builds is explained by MSVC's small-string optimization happening to place the inline character buffer at the start of the object — fragile and layout/compiler-dependent, which is why it broke on Win10 x64. mac_dest.c_str() returns a proper pointer to the null-terminated character data, so the fix is correct and portable.
It also brings setMacDest() in line with the neighboring setBcastDest(), which already uses bcast_dest.c_str() — explaining why the IP filter worked while the MAC filter didn't. The mac_dest.size() == 4 guard plus the null-terminated c_str() keeps the %2hhX%2hhX read safely in bounds.
Thanks for the fix.
Generated by Claude Code
- Bump version to 26.8.9 in hermes.rc (FILEVERSION/PRODUCTVERSION + strings) - Add 26.8.9 changelog entry to readme.txt for PR k3it#16 (TRX-DUO/Red Pitaya Protocol 2 fixes, P2 watchdog feed) and PR k3it#17 (fix MAC address DLL filter) - msbuild.yml: upload built HermesIntf.dll as a workflow artifact and auto-attach it to published GitHub releases Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SsVwSNXUxxufvxfb63DbT4
…fix MAC Address DLL Filter.
The IP Address filter is working fine, but when I tried the MAC filter it didn't work.
This is what Gemini AI had to say:
Because mac_dest is a std::string, passing (char *)&mac_dest takes the memory address of the C++ class object itself, not the text inside it. This corrupts the data reading and can cause your program to crash. Correct Code Use the .c_str() method to safely access the underlying C-style string
It is working for me now with that change. I'm not sure why this may have been working fine in the past and not on my Win10 X64 platform.