From 26cbd459fcc7cd7bed8256a5ad078c177a7a7fe2 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 7 Jan 2014 13:39:24 +0100 Subject: sms: Fix gsm_7bit legacy functions return value The legacy 7bit conversion functions (those without the '_n_' in the name) gave wrong return values on 64 bit platforms due to unproper signed/unsigned conversions and the usage of SIZE_MAX. This patch fixes this by using a smaller max size (see GSM_7BIT_LEGACY_MAX_BUFFER_SIZE, currently set to 64k) for the legacy wrappers and by using unsigned int for max_septets. In addition, there are tests now that check the return values of legacy encoding and decoding. Sponsored-by: On-Waves ehf --- include/osmocom/gsm/gsm_utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index f412e3e6..02bfe4cb 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -195,6 +195,9 @@ enum gsm_chan_t { }; /* Deprectated functions */ +/* Limit encoding and decoding to use no more than this amount of buffer bytes */ +#define GSM_7BIT_LEGACY_MAX_BUFFER_SIZE 0x10000 + int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n() instead"); int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length) OSMO_DEPRECATED("Use gsm_7bit_decode_n_ussd() instead"); int gsm_7bit_encode(uint8_t *result, const char *data) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead"); -- cgit v1.2.3