Skip to content

Fix problems detected by fortified builds#232

Merged
bbonev merged 10 commits intoeudev-project:masterfrom
bbonev:buffers
Jun 9, 2022
Merged

Fix problems detected by fortified builds#232
bbonev merged 10 commits intoeudev-project:masterfrom
bbonev:buffers

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

bbonev added 4 commits June 8, 2022 08:13
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
Copy link
Collaborator

@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.

bbonev added 6 commits June 9, 2022 19:03
Suggested-by: Arsen Arsenović <arsen@aarsen.me>
Suggested-by: Arsen Arsenović <arsen@aarsen.me>
- fix coding style while at it
- add checks and fail in case lockf failed

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
lseek and ftruncate may fail; do not continue the processing if that happens

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
Also fix code style of sizeof()

Suggested-by: Arsen Arsenović <arsen@aarsen.me>
Copy link
Collaborator

@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