[Git][wxwidgets/wxwidgets][master] 3 commits: Fix buffer overflow in deepCopyHostent() name copy

1 view
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 30, 2026, 7:32:48 PM (7 days ago) May 30
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 7348f005
    by dxbjavid at 2026-05-31T00:42:39+02:00
    Fix buffer overflow in deepCopyHostent() name copy
    
    This function, which is called by wxGethostby{name,addr}_r() if native
    implementations of these functions are not available, could overflow the
    input buffer by a byte if the host name was equal to the buffer size.
    
    Fix the check for length, which also makes it consistent with the check
    in deepCopyServent() just below.
    
    Closes #26528.
    
  • 4cf9de30
    by dxbjavid at 2026-05-31T00:51:52+02:00
    Fix integer overflow in tar extended header bounds check
    
    recSize in wxTarInputStream::ReadExtendedHeader() comes from the
    record's decimal byte-count field, so a pax header declaring a length
    close to SIZE_MAX makes recPos + recSize wrap below len and pass the
    check. The following pRec[recSize - 1] then reads far past the buffer,
    which ASAN flags as a heap-buffer-overflow.
    
    Comparing recSize against len - recPos avoids the wrap.
    
    Closes #26530.
    
  • 18582927
    by dxbjavid at 2026-05-31T00:57:30+02:00
    Fix out-of-bounds read on trailing % in wxFileType::ExpandCommand()
    
    A command ending in a bare '%' made the loop advance in this function
    advance past the end of string.
    
    Fix this by handling only non-trailing '%' specifically
    
    Closes #26531.
    

5 changed files:

Changes:

  • src/common/mimecmn.cpp
    ... ... @@ -138,7 +138,9 @@ wxString wxFileType::ExpandCommand(const wxString& command,
    138 138
     
    
    139 139
         wxString str;
    
    140 140
         for ( const wxChar *pc = command.c_str(); *pc != wxT('\0'); pc++ ) {
    
    141
    -        if ( *pc == wxT('%') ) {
    
    141
    +        // Make sure to leave any trailing '%' alone to avoid going past the
    
    142
    +        // end of string.
    
    143
    +        if ( *pc == wxT('%') && pc[1] != wxT('\0') ) {
    
    142 144
                 switch ( *++pc ) {
    
    143 145
                     case wxT('s'):
    
    144 146
                         // don't quote the file name if it's already quoted: notice
    

  • src/common/sckaddr.cpp
    ... ... @@ -131,7 +131,7 @@ hostent *deepCopyHostent(hostent *h,
    131 131
     
    
    132 132
         /* copy name */
    
    133 133
         int len = strlen(h->h_name);
    
    134
    -    if (len > size)
    
    134
    +    if (len >= size)
    
    135 135
         {
    
    136 136
             *err = ENOMEM;
    
    137 137
             return nullptr;
    

  • src/common/tarstrm.cpp
    ... ... @@ -933,8 +933,9 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
    933 933
             while (isdigit((unsigned char) *p))
    
    934 934
                 recSize = recSize * 10 + *p++ - '0';
    
    935 935
     
    
    936
    -        // validity checks
    
    937
    -        if (recPos + recSize > len)
    
    936
    +        // validity checks: write this carefully to avoid adding anything to
    
    937
    +        // recSize as addition could overflow
    
    938
    +        if (recSize > len - recPos)
    
    938 939
                 break;
    
    939 940
             if (recSize < p - pRec + (size_t)3 || *p != ' '
    
    940 941
                     || pRec[recSize - 1] != '\012') {
    

  • tests/archive/tartest.cpp
    ... ... @@ -16,6 +16,9 @@
    16 16
     
    
    17 17
     #include "archivetest.h"
    
    18 18
     #include "wx/tarstrm.h"
    
    19
    +#include "wx/mstream.h"
    
    20
    +
    
    21
    +#include <memory>
    
    19 22
     
    
    20 23
     using std::string;
    
    21 24
     
    
    ... ... @@ -69,4 +72,166 @@ CppUnit::Test *tartest::makeTest(
    69 72
     CPPUNIT_TEST_SUITE_REGISTRATION(tartest);
    
    70 73
     CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(tartest, "archive/tar");
    
    71 74
     
    
    75
    +TEST_CASE("Tar::BadExtendedHeaderRecordLen", "[tar][error]")
    
    76
    +{
    
    77
    +    // wxTarInputStream::ReadExtendedHeader() parses the records of a pax
    
    78
    +    // extended header ('x' type flag) and used "recPos + recSize > len" to
    
    79
    +    // check that a record fits in the buffer. recSize is parsed from the
    
    80
    +    // record's leading decimal byte count, so a record whose length is close
    
    81
    +    // to SIZE_MAX makes recPos + recSize overflow and wrap below len, passing
    
    82
    +    // the check. The subsequent "pRec[recSize - 1]" then reads far outside the
    
    83
    +    // buffer. The header below has a first valid record followed by a record
    
    84
    +    // whose declared length is 2^64 - 6, which triggers a heap-buffer-overflow
    
    85
    +    // read under ASAN. After the fix the oversized record is rejected and the
    
    86
    +    // following regular entry is returned normally.
    
    87
    +    static const unsigned char tarData[] = {
    
    88
    +        0x70, 0x61, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    89
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    90
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    91
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    92
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    93
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    94
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    95
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    96
    +        0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x36, 0x34, 0x34, 0x00,
    
    97
    +        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30,
    
    98
    +        0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
    
    99
    +        0x30, 0x33, 0x33, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
    
    100
    +        0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x36, 0x35, 0x36, 0x34, 0x00, 0x20,
    
    101
    +        0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    102
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    103
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    104
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    105
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    106
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    107
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    108
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    109
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30,
    
    110
    +        0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    111
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    112
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    113
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    114
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    115
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    116
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    117
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    118
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    119
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    120
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    121
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    122
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    123
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    124
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    125
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    126
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    127
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    128
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    129
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    130
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x20, 0x61, 0x3d,
    
    131
    +        0x62, 0x0a, 0x31, 0x38, 0x34, 0x34, 0x36, 0x37, 0x34, 0x34, 0x30, 0x37,
    
    132
    +        0x33, 0x37, 0x30, 0x39, 0x35, 0x35, 0x31, 0x36, 0x31, 0x30, 0x20, 0x00,
    
    133
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    134
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    135
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    136
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    137
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    138
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    139
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    140
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    141
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    142
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    143
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    144
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    145
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    146
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    147
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    148
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    149
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    150
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    151
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    152
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    153
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    154
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    155
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    156
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    157
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    158
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    159
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    160
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    161
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    162
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    163
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    164
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    165
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    166
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    167
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    168
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    169
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    170
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    171
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    172
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    173
    +        0x00, 0x00, 0x00, 0x00, 0x61, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x00, 0x00,
    
    174
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    175
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    176
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    177
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    178
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    179
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    180
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    181
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30,
    
    182
    +        0x36, 0x34, 0x34, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00,
    
    183
    +        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30,
    
    184
    +        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x30,
    
    185
    +        0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x30, 0x36, 0x37,
    
    186
    +        0x31, 0x34, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    187
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    188
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    189
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    190
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    191
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    192
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    193
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    194
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x73, 0x74,
    
    195
    +        0x61, 0x72, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    196
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    197
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    198
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    199
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    200
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    201
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    202
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    203
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    204
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    205
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    206
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    207
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    208
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    209
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    210
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    211
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    212
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    213
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    214
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    215
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    216
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    217
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    218
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    219
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    220
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    221
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    222
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    223
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    224
    +        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    
    225
    +    };
    
    226
    +
    
    227
    +    wxMemoryInputStream mis(tarData, sizeof(tarData));
    
    228
    +    wxTarInputStream tar(mis);
    
    229
    +    std::unique_ptr<wxTarEntry> entry(tar.GetNextEntry());
    
    230
    +
    
    231
    +    // Without the fix this reads out of bounds while parsing the extended
    
    232
    +    // header; with it the bad record is skipped and the normal entry is read.
    
    233
    +    REQUIRE( entry );
    
    234
    +    CHECK( entry->GetInternalName() == "a.txt" );
    
    235
    +}
    
    236
    +
    
    72 237
     #endif // wxUSE_STREAMS

  • tests/misc/misctests.cpp
    ... ... @@ -262,6 +262,17 @@ TEST_CASE("wxFileTypeInfo", "[mime]")
    262 262
             CHECK( fti.GetExtensions()[1] == "jpeg" );
    
    263 263
         }
    
    264 264
     }
    
    265
    +
    
    266
    +TEST_CASE("wxFileType::ExpandCommand", "[mime]")
    
    267
    +{
    
    268
    +    const wxFileType::MessageParameters params("file.txt", "text/plain");
    
    269
    +
    
    270
    +    CHECK( wxFileType::ExpandCommand("view %s", params) == "view file.txt" );
    
    271
    +
    
    272
    +    // A command ending with a bare '%' used to read past the end of the
    
    273
    +    // string; check that the trailing '%' is just copied verbatim instead.
    
    274
    +    CHECK( wxFileType::ExpandCommand("show %s %", params) == "show file.txt %" );
    
    275
    +}
    
    265 276
     #endif // wxUSE_MIMETYPE
    
    266 277
     
    
    267 278
     TEST_CASE("wxVersionInfo", "[version]")
    

Reply all
Reply to author
Forward
0 new messages