Add test for bug with PipeCapture crashing reading binary data (#777973)

A user had a very corrupt FAT file system and fsck.fat was reporting
binary data in file names with errors.  GParted crashed reading this
output.  Boiled down the problematic fsck.fat output to a sample 27
bytes which still triggers a crash and created a test for it.  The test
crashes test_PipeCapture program too.

    $ ./test_PipeCapture
    ...
    [ RUN      ] PipeCaptureTest.MinimalBinaryCrash777973
    Segmentation fault (core dumped)
    $ echo $?
    139

However it still produces a non-zero exit status and the autotools test
runner detects this so 'make check' still reports failure.

    $ make check
    ...
    make[2]: Entering directory `/home/centos/programming/c/gparted/tests'
    PASS: test_dummy
    PASS: test_BlockSpecial
    ../test-driver: line 95: 16152 Segmentation fault      "$@" > $log_file 2>&1
    FAIL: test_PipeCapture
    ...
    ============================================================================
    Testsuite summary for gparted 0.28.1-git
    ============================================================================
    # TOTAL: 3
    # PASS:  2
    # SKIP:  0
    # XFAIL: 0
    # FAIL:  1
    # XPASS: 0
    # ERROR: 0
    ============================================================================
    See tests/test-suite.log
    Please report to https://bugzilla.gnome.org/enter_bug.cgi?product=gparted
    ============================================================================
    make[2]: *** [test-suite.log] Error 1
    make[2]: Leaving directory `/home/centos/programming/c/gparted/tests'
    make[1]: *** [check-TESTS] Error 2
    make[1]: Leaving directory `/home/centos/programming/c/gparted/tests'
    make: *** [check-am] Error 2
    $ echo $?
    2

Bug 777973 - Segmentation fault on bad disk
This commit is contained in:
Mike Fleetwood 2017-05-24 13:35:44 +01:00 committed by Curtis Gedak
parent 8b47de8872
commit 1e3324e16b
1 changed files with 14 additions and 0 deletions

View File

@ -304,6 +304,20 @@ TEST_F( PipeCaptureTest, LongASCIITextWithUpdate )
EXPECT_TRUE( eof_signalled ); EXPECT_TRUE( eof_signalled );
} }
TEST_F( PipeCaptureTest, MinimalBinaryCrash777973 )
{
// Test for bug #777973. Minimal test case of binary data returned by fsck.fat
// as file names from a very corrupt FAT, leading to GParted crashing from a
// segmentation fault.
inputstr = "/LOST.DIR/!\xE2\x95\x9F\xE2\x88\xA9\xC2\xA0!\xE2\x95\x9F\xE2\x88\xA9\xC2";
PipeCapture pc( pipefds[ReaderFD], capturedstr );
pc.signal_eof.connect( sigc::mem_fun( *this, &PipeCaptureTest::eof_callback ) );
pc.connect_signal();
run_writer_thread();
EXPECT_BINARYSTRINGEQ( inputstr, capturedstr.raw() );
EXPECT_TRUE( eof_signalled );
}
} // namespace GParted } // namespace GParted
// Custom Google Test main() which also initialises the Glib threading system for // Custom Google Test main() which also initialises the Glib threading system for