Commit d4bfc6a
Fix potential UB in string concatenation for NFLog device name. (#1844)
* Fix potential UB in string concatenation for NFLog device name.
Fixes a build failure with GCC 12.2.0 on aarch64 due to overly aggressive optimizations and inlining when concatenating C-style and temporary C++ strings using operator+.
The original code caused a -Werror=restrict warning about possible memory overlap in std::char_traits<char>::copy.
```code
inlined from ‘pcpp::internal::PcapHandle pcpp::PcapLiveDevice::doOpen(const DeviceConfiguration&)’ at app/connectivity/build/rpi64-rls/_deps/pcapplusplus-src/Pcap++/src/PcapLiveDevice.cpp:386:23:
app/connectivity/3rdparty/cross/rpi64/tools/gcc-12.2.0-64/aarch64-linux-gnu/include/c++/12.2.0/bits/char_traits.h:431:56: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
431 | return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
```
* add comment
* apply clang-format
---------
Co-authored-by: Liu, An-Chi <phy.tiger@gmail.com>1 parent 1674286 commit d4bfc6a
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
| 430 | + | |
| 431 | + | |
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
| |||
0 commit comments