ECC-1994: Crash: grib_compare combining -b and -r flag

This commit is contained in:
Shahram Najm 2024-12-13 17:30:54 +00:00
parent 9dc994bedb
commit 67d1bad7ef
1 changed files with 4 additions and 1 deletions

View File

@ -102,6 +102,7 @@ int grib_accessor_md5_t::unpack_string(char* v, size_t* len)
mess = (unsigned char*)grib_context_malloc(context_, length); mess = (unsigned char*)grib_context_malloc(context_, length);
memcpy(mess, grib_handle_of_accessor(this)->buffer->data + offset, length); memcpy(mess, grib_handle_of_accessor(this)->buffer->data + offset, length);
mess_len = length; mess_len = length;
const unsigned char* pEnd = mess + length - 1;
blocklist = context_->blocklist; blocklist = context_->blocklist;
/* passed blocklist overrides context blocklist. /* passed blocklist overrides context blocklist.
@ -117,8 +118,10 @@ int grib_accessor_md5_t::unpack_string(char* v, size_t* len)
} }
p = mess + b->offset_ - offset; p = mess + b->offset_ - offset;
for (i = 0; i < b->length_; i++) for (i = 0; i < b->length_; i++) {
if (p > pEnd) break;
*(p++) = 0; *(p++) = 0;
}
blocklist = blocklist->next; blocklist = blocklist->next;
} }