mirror of https://github.com/ecmwf/eccodes.git
ECC-1167: fix unpack_string length
This commit is contained in:
parent
29120ff9dd
commit
7f4047280e
|
@ -157,10 +157,11 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
|
|||
unsigned char* p = NULL;
|
||||
char* s = v;
|
||||
int i;
|
||||
long length = grib_byte_count(a);
|
||||
const long length = grib_byte_count(a);
|
||||
const long slength = 2 * length;
|
||||
|
||||
if (*len < 2 * length) {
|
||||
*len = 2 * length;
|
||||
if (*len < slength) {
|
||||
*len = slength;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,7 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
|
|||
s += 2;
|
||||
}
|
||||
|
||||
*len = length;
|
||||
*len = slength;
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue