Changeset 19024 in josm for trunk/test


Ignore:
Timestamp:
2024-04-02T18:57:56+02:00 (3 months ago)
Author:
taylor.smock
Message:

Fix #23550: Error when deserializing PBF Blog (patch by giora.kosoi, modified)

Modifications are as follows:

  • Added non-regression test
  • Removed unnecessary changes in Blob
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/io/importexport/OsmPbfImporterTest.java

    r18828 r19024  
    143143        assertNotNull(dataSet.getPrimitiveById(9223372036854775806L, OsmPrimitiveType.RELATION));
    144144    }
     145
     146    /**
     147     * Non-regression test for #23550: Error when deserializing PBF blob when generator writes the blob <i>then</i>
     148     * the compression type.
     149     */
     150    @Test
     151    void testNonRegression23550() {
     152        final byte[] badData = HEADER_DATA.clone();
     153        final byte[] sizeInfo = Arrays.copyOfRange(badData, 18, 21);
     154        for (int i = 18; i < badData.length - sizeInfo.length; i++) {
     155            badData[i] = badData[i + sizeInfo.length];
     156        }
     157        System.arraycopy(sizeInfo, 0, badData, badData.length - 3, 3);
     158        // the data doesn't include any "real" data, but the problematic code path is exercised by the header parsing code.
     159        assertDoesNotThrow(() -> importer.parseDataSet(new ByteArrayInputStream(badData), NullProgressMonitor.INSTANCE));
     160    }
    145161}
Note: See TracChangeset for help on using the changeset viewer.