mirror of https://github.com/ecmwf/eccodes.git
ECC-1347: BUFR crash: malloc failure during encoding
This commit is contained in:
parent
2736648f41
commit
ed8a8a3447
|
@ -1381,7 +1381,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array
|
|||
int err = 0;
|
||||
unsigned long repetitions = 1;
|
||||
bufr_descriptor** descriptors = self->expanded->v;
|
||||
/* Assert( buff->data==data); */
|
||||
DebugAssert( buff->data == data );
|
||||
|
||||
switch (descriptors[i]->code) {
|
||||
case 31000:
|
||||
|
@ -1425,6 +1425,7 @@ static int encode_new_replication(grib_context* c, grib_accessor_bufr_data_array
|
|||
grib_context_log(c, GRIB_LOG_DEBUG, "BUFR data encoding replication: \twidth=%ld pos=%ld ulength=%ld ulength_bits=%ld",
|
||||
(long)descriptors[i]->width, (long)*pos, (long)buff->ulength, (long)buff->ulength_bits);
|
||||
grib_buffer_set_ulength_bits(c, buff, buff->ulength_bits + descriptors[i]->width);
|
||||
data = buff->data; /* ECC-1347 */
|
||||
grib_encode_unsigned_longb(data, repetitions, pos, descriptors[i]->width);
|
||||
|
||||
*numberOfRepetitions = repetitions;
|
||||
|
|
|
@ -99,6 +99,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
bufr_ecc-1259
|
||||
bufr_ecc-1290
|
||||
bufr_ecc-1304
|
||||
bufr_ecc-1347
|
||||
bufr_json_samples
|
||||
bufr_ecc-359
|
||||
bufr_ecc-517
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
# (C) Copyright 2005- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.sh
|
||||
|
||||
set -u
|
||||
|
||||
label="bufr_ecc-1347-test"
|
||||
tempBufr=temp.$label.bufr
|
||||
tempFilt=temp.$label.filter
|
||||
|
||||
sample_bufr3=$ECCODES_SAMPLES_PATH/BUFR3.tmpl
|
||||
|
||||
cat > $tempFilt <<EOF
|
||||
set inputDelayedDescriptorReplicationFactor= {0};
|
||||
set inputExtendedDelayedDescriptorReplicationFactor= {1458};
|
||||
set masterTableNumber=0;
|
||||
set bufrHeaderSubCentre=0;
|
||||
set bufrHeaderCentre=98;
|
||||
set updateSequenceNumber=1;
|
||||
set dataCategory=2;
|
||||
set dataSubCategory=0;
|
||||
set masterTablesVersionNumber=27;
|
||||
set localTablesVersionNumber=0;
|
||||
set numberOfSubsets=1;
|
||||
set observedData=1;
|
||||
set compressedData=0;
|
||||
set unexpandedDescriptors={
|
||||
301128, 7007, 2102, 201133, 25065, 25066, 201000, 309052, 205011,
|
||||
5001, 6001, 7001 };
|
||||
write;
|
||||
EOF
|
||||
|
||||
${tools_dir}/codes_bufr_filter -o $tempBufr $tempFilt $sample_bufr3
|
||||
${tools_dir}/bufr_dump -p $tempBufr
|
||||
|
||||
rm -f $tempBufr $tempFilt
|
Loading…
Reference in New Issue