From 8212fc6a7d9cfd6c5e71f522863c3e3420262360 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 1 Apr 2019 14:34:37 +0200 Subject: add gsm48_decode_bcd_number2() from osmo-msc gsm48_decode_bcd_number() is unable to provide proper bounds validation of input and output data, hence osmo-msc's vlr.c introduced a static decode_bcd_number_safe() a long time ago. Move to libosmocore. I need to use the same function to decode an MSISDN during inter-MSC Handover, instead of making it public in osmo-msc, rather deprecate the unsafe function and provide a safer version for all callers. Mark the old one deprecated. Change-Id: Idb6ae6e2f3bea11ad420dae14d021ac36d99e921 --- include/osmocom/gsm/gsm48_ie.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/osmocom') diff --git a/include/osmocom/gsm/gsm48_ie.h b/include/osmocom/gsm/gsm48_ie.h index f7cc24ea..71050df5 100644 --- a/include/osmocom/gsm/gsm48_ie.h +++ b/include/osmocom/gsm/gsm48_ie.h @@ -13,7 +13,11 @@ /* decode a 'called/calling/connect party BCD number' as in 10.5.4.7 */ int gsm48_decode_bcd_number(char *output, int output_len, - const uint8_t *bcd_lv, int h_len); + const uint8_t *bcd_lv, int h_len) + OSMO_DEPRECATED("Use gsm48_decode_bcd_number2() for improved bounds checking"); +int gsm48_decode_bcd_number2(char *output, size_t output_len, + const uint8_t *bcd_lv, size_t input_len, + size_t h_len); /* convert a ASCII phone number to 'called/calling/connect party BCD number' */ int gsm48_encode_bcd_number(uint8_t *bcd_lv, uint8_t max_len, -- cgit v1.2.3