Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems detected by fortified builds #232

Merged
merged 10 commits into from
Jun 9, 2022

Conversation

bbonev
Copy link
Member

@bbonev bbonev commented Jun 8, 2022

  • do not overwrite memory (-pre versions trigger this)
  • do not use truncated strings
  • kill the warnings for unused result

tested on gcc 11.3 with:

CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2" \
CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \
LDFLAGS="-Wl,-z,relro -Wl,-z,now" \
./configure && \
make -j

This condition may happen with version as 3.2.12-pre1 which would generate
udev-3.2.12-pre1 with length of 17 including the terminating 0, while
struct udev_ctrl.version is only 16 bytes
In case of invalid input the resulting modalias would exceed the buffer and be
truncated. Add checks to avoid generating truncated modalias.
ftruncate and lockf are declared with attribute ‘warn_unused_result’.
Kill the warning and add a TODO comment.
Add a check to avoid creating files with path that may be truncated
@bbonev bbonev requested review from ArsenArsen and kaniini June 8, 2022 05:34
@bbonev bbonev changed the title Fix warnings detected by fortified builds Fix problems detected by fortified builds Jun 8, 2022
src/collect/collect.c Outdated Show resolved Hide resolved
src/collect/collect.c Show resolved Hide resolved
src/collect/collect.c Outdated Show resolved Hide resolved
src/collect/collect.c Outdated Show resolved Hide resolved
src/udev/udev-ctrl.c Outdated Show resolved Hide resolved
Copy link
Member

@ArsenArsen ArsenArsen left a comment

Choose a reason for hiding this comment

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

see above, I selected the wrong option by mistake.

Suggested-by: Arsen Arsenović <[email protected]>
Suggested-by: Arsen Arsenović <[email protected]>
- fix coding style while at it
- add checks and fail in case lockf failed

Suggested-by: Arsen Arsenović <[email protected]>
lseek and ftruncate may fail; do not continue the processing if that happens

Suggested-by: Arsen Arsenović <[email protected]>
Also fix code style of sizeof()

Suggested-by: Arsen Arsenović <[email protected]>
Copy link
Member

@ArsenArsen ArsenArsen left a comment

Choose a reason for hiding this comment

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

looks alright

@bbonev bbonev merged commit 3211655 into eudev-project:master Jun 9, 2022
@bbonev bbonev deleted the buffers branch June 11, 2022 14:50
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.

2 participants