Discussion:
[Bug cli/23785] New: Segmentation fault (restore non-existent-file binary)
lijiang1489 at 163 dot com
2018-10-16 20:48:21 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

Bug ID: 23785
Summary: Segmentation fault (restore non-existent-file binary)
Product: gdb
Version: 8.2
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: cli
Assignee: unassigned at sourceware dot org
Reporter: lijiang1489 at 163 dot com
Target Milestone: ---

In gdb8.x, in all targets, if users tried to restore a non-existent file using
gdb cmd "restore wkefjw binary", gdb crashed.

I have checked function “restore_binary_file()” in gdb/cli/cli-dump.c, it got
"file" from "gdb_fopen_cloexec()". In "gdb_fopen_cloexec()", it does not error
out when fopen() got a NULL file pointer.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-18 11:31:46 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |sergiodj at redhat dot com

--- Comment #1 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Patch submitted: https://sourceware.org/ml/gdb-patches/2018-10/msg00396.html.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-18 18:29:19 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2018-10-18
Assignee|unassigned at sourceware dot org |sergiodj at redhat dot com
Ever confirmed|0 |1
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-10-18 21:40:18 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sergio Durigan Junior
<***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=94c18618a8e29894a7b3104375e0510d71a568fb

commit 94c18618a8e29894a7b3104375e0510d71a568fb
Author: Sergio Durigan Junior <***@redhat.com>
Date: Thu Oct 18 12:56:25 2018 -0400

Fix PR cli/23785: Check if file exists when invoking "restore FILE binary"

This simple patch fixes the segfault reported on PR cli/23785, which
happens when using the "restore FILE binary" command with a
non-existent file. We just have to check if the file handler returned
by "gdb_fopen_cloexec" is not NULL, and error out if it is.

A test has also been added to gdb.base/restore.exp in order to
exercise this scenario.

No regressions introduced.

gdb/ChangeLog:
2018-10-18 Sergio Durigan Junior <***@redhat.com>

PR cli/23785
* cli/cli-dump.c (restore_binary_file): Check if "file" is
NULL.

gdb/testsuite/ChangeLog:
2018-10-18 Sergio Durigan Junior <***@redhat.com>

PR cli/23785
* gdb.base/restore.exp: New test to check if "restore" with an
invalid file doesn't segfault.
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-10-18 16:11:39 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED

--- Comment #3 from Sergio Durigan Junior <sergiodj at redhat dot com> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-11-14 10:37:28 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23785

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Target Milestone|--- |8.3
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...