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



commit 1e3324e16b5e63d81289c8d44ce9f166faf9ed47
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed May 24 13:35:44 2017 +0100

    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

 tests/test_PipeCapture.cc |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_PipeCapture.cc b/tests/test_PipeCapture.cc
index 49b5630..ddced6c 100644
--- a/tests/test_PipeCapture.cc
+++ b/tests/test_PipeCapture.cc
@@ -304,6 +304,20 @@ TEST_F( PipeCaptureTest, LongASCIITextWithUpdate )
        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
 
 // Custom Google Test main() which also initialises the Glib threading system for


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]