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.
This commit is contained in:
Todd C. Miller 2021-10-01 15:15:24 -06:00 committed by GitHub
parent 287e35cd4d
commit aca2552874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

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