Blame src/plugins/abrt-action-analyze-vulnerability.in

Packit Service 8a8a03
#!/bin/sh
Packit Service 8a8a03
Packit Service 8a8a03
# Do we have the tools we need?
Packit Service 8a8a03
# If no, exit silently.
Packit Service 8a8a03
command -v @GDB@ >/dev/null 2>&1 || exit 0
Packit Service 8a8a03
command -v eu-readelf >/dev/null 2>&1 || exit 0
Packit Service 8a8a03
Packit Service 8a8a03
# Do we have coredump?
Packit Service 8a8a03
test -r coredump || {
Packit Service 8a8a03
    echo 'No file "coredump" in current directory' >&2
Packit Service 8a8a03
    exit 1
Packit Service 8a8a03
}
Packit Service 8a8a03
Packit Service 8a8a03
# Find "cursig: N" and extract N.
Packit Service 8a8a03
# This gets used by abrt-exploitable as a fallback
Packit Service 8a8a03
# if gdb and/or kernel is uncooperative.
Packit Service 8a8a03
# "grep -m1": take the first match (on Linux, every thread has its own
Packit Service 8a8a03
# prstatus struct in the coredump, but the signal number which killed us
Packit Service 8a8a03
# must be the same in all these structs).
Packit Service 8a8a03
SIGNO_OF_THE_COREDUMP=$(eu-readelf -n coredump | grep -m1 -o 'cursig: *[0-9]*' | sed 's/[^0-9]//g')
Packit Service 8a8a03
export SIGNO_OF_THE_COREDUMP
Packit Service 8a8a03
Packit Service 8a8a03
# Run gdb, hiding its messages. Example:
Packit Service 8a8a03
#   Missing separate debuginfo for the main executable file
Packit Service 8a8a03
#   Core was generated by...
Packit Service 8a8a03
#   Program terminated with signal 11, Segmentation fault.
Packit Service 8a8a03
#   #0  0x09fa5348 in ?? ()
Packit Service 8a8a03
# We don't want to see all this.
Packit Service 8a8a03
# abrt-exploitable plugin is instructed to create ./exploitable file
Packit Service 8a8a03
# with explanation if severity is >= 4
Packit Service 8a8a03
GDBOUT=$(
Packit Service 8a8a03
@GDB@ --batch \
Packit Service 8a8a03
    -ex 'python exec(open("/usr/libexec/abrt-gdb-exploitable").read())' \
Packit Service 8a8a03
    -ex 'core-file ./coredump' \
Packit Service 8a8a03
    -ex 'abrt-exploitable 4 ./exploitable' \
Packit Service 8a8a03
    2>&1 \
Packit Service 8a8a03
) && exit 0
Packit Service 8a8a03
Packit Service 8a8a03
# There was an error. Show the messages.
Packit Service 8a8a03
printf "Error while running gdb:\n%s\n" "$GDBOUT"
Packit Service 8a8a03
exit 1