Changeset 19024 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java
r18877 r19024 185 185 int size = Integer.MIN_VALUE; 186 186 Blob.CompressionType type = null; 187 ProtobufRecord current = null; 187 ProtobufRecord current; 188 // Needed since size and compression type + compression data may be in a different order 189 byte [] bytes = null; 188 190 while (parser.hasNext() && cis.getBytesRead() - start < header.dataSize()) { 189 191 current = new ProtobufRecord(baos, parser); … … 191 193 case 1: 192 194 type = Blob.CompressionType.raw; 195 bytes = current.getBytes(); 193 196 break; 194 197 case 2: … … 197 200 case 3: 198 201 type = Blob.CompressionType.zlib; 202 bytes = current.getBytes(); 199 203 break; 200 204 case 4: 201 205 type = Blob.CompressionType.lzma; 206 bytes = current.getBytes(); 202 207 break; 203 208 case 5: 204 209 type = Blob.CompressionType.bzip2; 210 bytes = current.getBytes(); 205 211 break; 206 212 case 6: 207 213 type = Blob.CompressionType.lz4; 214 bytes = current.getBytes(); 208 215 break; 209 216 case 7: 210 217 type = Blob.CompressionType.zstd; 218 bytes = current.getBytes(); 211 219 break; 212 220 default: … … 217 225 throw new IllegalStateException("Compression type not found, pbf may be malformed"); 218 226 } 219 return new Blob(size, type, current.getBytes());227 return new Blob(size, type, bytes); 220 228 } 221 229 -
trunk/test/unit/org/openstreetmap/josm/gui/io/importexport/OsmPbfImporterTest.java
r18828 r19024 143 143 assertNotNull(dataSet.getPrimitiveById(9223372036854775806L, OsmPrimitiveType.RELATION)); 144 144 } 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 } 145 161 }
Note:
See TracChangeset
for help on using the changeset viewer.