forked from OpenEtherCATsociety/SOEM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some UB cases. Closes OpenEtherCATsociety#546
There are two cases of UB that are fixed in this commit. 1. In ethercatmain.c, there are two left shifts of 31: (1 << 31) Because 1 is a signed int by default, the result cannot be represented in an int. The fix is to explicitly make the 1 unsigned. 2. In ethercatconfig.c, for slaves that have no inputs, the code would apply an offset to a NULL pointer. The fix is to test that the slave has inputs available before applying the offset. Both cases were found by clang with the help of UBSan.
- Loading branch information
Showing
2 changed files
with
6 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters