mirror of https://github.com/PentHertz/srsLTE.git
Fixed unpack bytes limit
This commit is contained in:
parent
05fbca43d1
commit
4ed33fed7d
|
@ -237,15 +237,20 @@ SRSASN_CODE bit_ref_impl<Ptr>::unpack_bytes(uint8_t* buf, uint32_t n_bytes)
|
||||||
if (n_bytes == 0) {
|
if (n_bytes == 0) {
|
||||||
return SRSASN_SUCCESS;
|
return SRSASN_SUCCESS;
|
||||||
}
|
}
|
||||||
if (ptr + n_bytes >= max_ptr) {
|
|
||||||
log_error("Buffer size limit was achieved");
|
|
||||||
return SRSASN_ERROR_DECODE_FAIL;
|
|
||||||
}
|
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
// Aligned case
|
// Aligned case
|
||||||
|
if (ptr + n_bytes > max_ptr) {
|
||||||
|
log_error("Buffer size limit was achieved");
|
||||||
|
return SRSASN_ERROR_DECODE_FAIL;
|
||||||
|
}
|
||||||
memcpy(buf, ptr, n_bytes);
|
memcpy(buf, ptr, n_bytes);
|
||||||
ptr += n_bytes;
|
ptr += n_bytes;
|
||||||
} else {
|
} else {
|
||||||
|
// Unaligned case
|
||||||
|
if (ptr + n_bytes >= max_ptr) {
|
||||||
|
log_error("Buffer size limit was achieved");
|
||||||
|
return SRSASN_ERROR_DECODE_FAIL;
|
||||||
|
}
|
||||||
for (uint32_t i = 0; i < n_bytes; ++i) {
|
for (uint32_t i = 0; i < n_bytes; ++i) {
|
||||||
HANDLE_CODE(unpack(buf[i], 8));
|
HANDLE_CODE(unpack(buf[i], 8));
|
||||||
}
|
}
|
||||||
|
@ -274,7 +279,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::advance_bits(uint32_t n_bits)
|
||||||
uint32_t bytes_required = ceilf((offset + n_bits) / 8.0f);
|
uint32_t bytes_required = ceilf((offset + n_bits) / 8.0f);
|
||||||
uint32_t bytes_offset = floorf((offset + n_bits) / 8.0f);
|
uint32_t bytes_offset = floorf((offset + n_bits) / 8.0f);
|
||||||
|
|
||||||
if (ptr + bytes_required >= max_ptr) {
|
if (ptr + bytes_required > max_ptr) {
|
||||||
log_error("Buffer size limit was achieved");
|
log_error("Buffer size limit was achieved");
|
||||||
return SRSASN_ERROR_DECODE_FAIL;
|
return SRSASN_ERROR_DECODE_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue