path: root/include/osmocom
diff options
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-01-30 01:31:32 +0100
committerfixeria <vyanitskiy@sysmocom.de>2021-02-01 17:47:54 +0000
commit943133cad89cc133dbe9fba8fc19249ce57d33ad (patch)
tree41e4c160300603cf63a0bc897a83ecccd071e874 /include/osmocom
parent44ac4f6c9294abdbc5344b68b49b088e7f67b0ff (diff)
gsm_7bit_encode_n(): fix integer overflow in gsm_septets2octets()
Using 'uint8_t' for the length argument is definitely a bad idea. Because of this, packing more than 255 septets would not work as expected. Deprecate the old function and use 'size_t' instead. Change-Id: Ib1aac538afeb0a5c76a1df472d555139a496e12e
Diffstat (limited to 'include/osmocom')
1 files changed, 4 insertions, 1 deletions
diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h
index de634348..0909006e 100644
--- a/include/osmocom/gsm/gsm_utils.h
+++ b/include/osmocom/gsm/gsm_utils.h
@@ -110,7 +110,10 @@ int gsm_7bit_encode_n(uint8_t *result, size_t n, const char *data, int *octets_w
int gsm_7bit_encode_n_ussd(uint8_t *result, size_t n, const char *data, int *octets_written);
/* the four functions below are helper functions and here for the unit test */
-int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding);
+int gsm_septets2octets(uint8_t *result, const uint8_t *rdata, uint8_t septet_len, uint8_t padding)
+ OSMO_DEPRECATED("This function is unable to handle more than 255 septets, "
+ "use gsm_septet_pack() instead.");
+int gsm_septet_pack(uint8_t *result, const uint8_t *rdata, size_t septet_len, uint8_t padding);
int gsm_septet_encode(uint8_t *result, const char *data);
uint8_t gsm_get_octet_len(const uint8_t sept_len);
int gsm_7bit_decode_n_hdr(char *decoded, size_t n, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind);