Clarify error message.

master
Fabian Eckermann 3 years ago committed by Andre Puschmann
parent 04d3e516af
commit 361054da12

@ -144,7 +144,7 @@ SRSASN_CODE bit_ref::pack(uint64_t val, uint32_t n_bits)
uint64_t mask; uint64_t mask;
while (n_bits > 0) { while (n_bits > 0) {
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("pack: Buffer size limit was achieved");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
mask = ((1ul << n_bits) - 1ul); mask = ((1ul << n_bits) - 1ul);
@ -176,7 +176,7 @@ SRSASN_CODE unpack_bits(T& val, Ptr& ptr, uint8_t& offset, const uint8_t* max_pt
val = 0; val = 0;
while (n_bits > 0) { while (n_bits > 0) {
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("unpack_bits: Buffer size limit was achieved");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
if ((uint32_t)(8 - offset) > n_bits) { if ((uint32_t)(8 - offset) > n_bits) {
@ -240,7 +240,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::unpack_bytes(uint8_t* buf, uint32_t n_bytes)
if (offset == 0) { if (offset == 0) {
// Aligned case // Aligned case
if (ptr + n_bytes > max_ptr) { if (ptr + n_bytes > max_ptr) {
log_error("Buffer size limit was achieved"); log_error("unpack_bytes (aligned): Buffer size limit was achieved");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
memcpy(buf, ptr, n_bytes); memcpy(buf, ptr, n_bytes);
@ -248,7 +248,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::unpack_bytes(uint8_t* buf, uint32_t n_bytes)
} else { } else {
// Unaligned case // Unaligned case
if (ptr + n_bytes >= max_ptr) { if (ptr + n_bytes >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("unpack_bytes (unaligned): Buffer size limit was achieved");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
for (uint32_t i = 0; i < n_bytes; ++i) { for (uint32_t i = 0; i < n_bytes; ++i) {
@ -264,7 +264,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::align_bytes()
if (offset == 0) if (offset == 0)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("align_bytes: Buffer size limit was achieved");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
offset = 0; offset = 0;
@ -280,7 +280,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::advance_bits(uint32_t n_bits)
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("advance_bytes: Buffer size limit was achieved");
return SRSASN_ERROR_DECODE_FAIL; return SRSASN_ERROR_DECODE_FAIL;
} }
ptr += bytes_offset; ptr += bytes_offset;
@ -306,7 +306,7 @@ SRSASN_CODE bit_ref::pack_bytes(const uint8_t* buf, uint32_t n_bytes)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
} }
if (ptr + n_bytes >= max_ptr) { if (ptr + n_bytes >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("pack_bytes: Buffer size limit was achieved");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
if (offset == 0) { if (offset == 0) {
@ -326,7 +326,7 @@ SRSASN_CODE bit_ref::align_bytes_zero()
if (offset == 0) if (offset == 0)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;
if (ptr >= max_ptr) { if (ptr >= max_ptr) {
log_error("Buffer size limit was achieved"); log_error("align_bytes_zero: Buffer size limit was achieved");
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
auto mask = static_cast<uint8_t>(256u - (1u << (8u - offset))); auto mask = static_cast<uint8_t>(256u - (1u << (8u - offset)));

Loading…
Cancel
Save