Skip to content

Conversation

@m-pellizzer
Copy link

The strcpy calls in sample.c caused segmentation fault on kernels with CONFIG_FORTIFY_SOURCE enabled. This occurs because strcpy is compiled as a memcpy (preceded by a strlen), which violates memory alignment constraints and lead to a crash.

To resolve the issue, all strcpy calls in sample.c were replaced with a byte-by-byte copy, ensuring that no unaligned access occurs.

Tested on both kernels with and without CONFIG_FORTIFY_SOURCE to ensure compatibility and to confirm that the changes prevent the segfault.

The strcpy calls in sample.c caused segmentation fault on kernels with CONFIG_FORTIFY_SOURCE
enabled. This occurs because strcpy is compiled as a memcpy (preceded
by a strlen), which violates memory alignment constraints and lead to a
crash.

To resolve the issue, all strcpy calls in sample.c were replaced with a
byte-by-byte copy, ensuring that no unaligned access occurs.

Tested on both kernels with and without CONFIG_FORTIFY_SOURCE to ensure
compatibility and to confirm that the changes prevent the segfault.

Signed-off-by: Massimiliano Pellizzer <massimiliano.pellizzer@canonical.com>
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.

1 participant