diff options
author | Todd C. Miller <Todd.Miller@sudo.ws> | 2021-10-01 15:15:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 22:15:24 +0100 |
commit | aca25528747082f711ab5cc8b019acaad1310841 (patch) | |
tree | 56a7dca99dede0e31f94b816faec080a24abb868 | |
parent | 287e35cd4df1f59f28fe9ceb2123688c86fb83fa (diff) | |
download | oss-fuzz-aca25528747082f711ab5cc8b019acaad1310841.tar.gz |
sudoers: set optimization flag in LDFLAGS for the object size sanitizer (#6544)
Sudo does not link executables using CFLAGS, only LDFLAGS.
When building with UBSan, the compiler warns that the object size
sanitizer has no effect at -O0 but is explicitly enabled.
-rwxr-xr-x | projects/sudoers/build.sh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/projects/sudoers/build.sh b/projects/sudoers/build.sh index 905450cb4..d157c9a63 100755 --- a/projects/sudoers/build.sh +++ b/projects/sudoers/build.sh @@ -28,7 +28,11 @@ else sanitizer_opts="$SANITIZER_FLAGS" fi # This is already added by --enable-fuzzer -CFLAGS="`echo \"$CFLAGS\" | sed \"s/ -fsanitize=fuzzer-no-link//\"`" +CFLAGS="`echo \"$CFLAGS\" | sed 's/ -fsanitize=fuzzer-no-link//'`" + +# Copy optimization flag to LDFLAGS for UBSan object-size check. +OPTFLAG="`echo \"$CFLAGS\" | sed 's/^.*\(-O[^ ]\).*$/\1/'`" +export LDFLAGS="${LDFLAGS:-}${LDFLAGS:+ }$OPTFLAG" # Build sudo with static libs and enable fuzzing targets. # All fuzz targets are integrated into the build process. |