smsutil: Use size_t for lengths and offsets
PATCH 1/1 smsutil: Use size_t for lengths and offsets
For some unknown reason 'int' was used as the data type for length and offset values, which can never be negative. Fix that.
--- src/message-waiting.c | 6 ++- src/smsutil.c | 120 +++++++++++++++++++++--------------------- src/smsutil.h | 22 ++++---- src/stkutil.c | 4 +- 4 files changed, 78 insertions(+), 74 deletions(-)
src/message-waiting.c +4 -2
@@ -782,9 +782,11 @@ static void handle_special_sms_iei(struct ofono_message_waiting *mw,static void handle_enhanced_voicemail_iei (struct ofono_message_waiting *mw,const guint8 *iei, -gboolean *discard,int length) +gboolean *discard, +size_t length) { -int profile, n; +int profile; +size_t n;gboolean set;struct sms_address mailbox_address;
src/smsutil.c +61 -59
387 lines not on this page · raw message
src/smsutil.h +11 -11
@@ -413,13 +413,13 @@ static inline unsigned char bit_field(unsigned char oct, int start, int num)return (oct >> start) & mask; } -void extract_bcd_number (const unsigned char *buf,int len,char *out); +void extract_bcd_number (const unsigned char *buf,size_t len,char *out);void encode_bcd_number (const char *number,unsigned char *out); -gboolean sms_decode (const unsigned char *pdu,int len,gboolean outgoing, -int tpdu_len,struct sms *out); +gboolean sms_decode (const unsigned char *pdu,size_t len,gboolean outgoing, +size_t tpdu_len,struct sms *out); -gboolean sms_decode_unpacked_stk_pdu (const unsigned char *pdu,int len, +gboolean sms_decode_unpacked_stk_pdu (const unsigned char *pdu,size_t len,struct sms *out); gboolean sms_encode(const struct sms *in, int *len, int *tpdu_len,
@@ -431,22 +431,22 @@ gboolean sms_encode(const struct sms *in, int *len, int *tpdu_len,*/ #define DECLARE_SMS_ADDR_STR (a) char a[25] -gboolean sms_decode_address_field (const unsigned char *pdu,int len, -int *offset,gboolean sc, +gboolean sms_decode_address_field (const unsigned char *pdu,size_t len, +size_t *offset,gboolean sc,struct sms_address *out);gboolean sms_encode_address_field (const struct sms_address *in,gboolean sc, -unsigned char *pdu,int *offset); +unsigned char *pdu,size_t *offset);guint8 sms_decode_semi_octet (guint8 in); -gboolean sms_decode_scts (const unsigned char *pdu,int len, -int *offset,struct sms_scts *out); +gboolean sms_decode_scts (const unsigned char *pdu,size_t len, +size_t *offset,struct sms_scts *out);gboolean sms_encode_scts (const struct sms_scts *in,unsigned char *pdu, -int *offset); +size_t *offset); -int sms_udl_in_bytes (guint8 ud_len,guint8 dcs); +size_t sms_udl_in_bytes (guint8 ud_len,guint8 dcs);time_t sms_scts_to_time (const struct sms_scts *scts,struct tm *remote);
src/stkutil.c +2 -2
@@ -1026,7 +1026,7 @@ static bool parse_dataobj_datetime_timezone( {struct sms_scts *scts = user;const uint8_t *data; -int offset =0 ; +size_t offset =0 ;if (comprehension_tlv_iter_get_length (iter) !=7 )return false;
@@ -4690,7 +4690,7 @@ static bool build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv, {const struct sms_scts *scts = data;uint8_t value[7 ]; -int offset =0 ; +size_t offset =0 ;uint8_t tag =STK_DATA_OBJECT_TYPE_DATETIME_TIMEZONE ;if (scts->month ==0 && scts->day ==0 )
Signature · 1 line
2.47.0
This patch was applied to ofono.git (master) by Denis Kenzior <[email protected]>:
Hello:
This patch was applied to ofono.git (master)
by Denis Kenzior <[email protected]>:
Quoted 8 lines · On Wed, 4 Dec 2024 12:34:25 -0600 you wrote:
For some unknown reason 'int' was used as the data type for length and offset values, which can never be negative. Fix that.
--- src/message-waiting.c | 6 ++- src/smsutil.c | 120 +++++++++++++++++++++--------------------- src/smsutil.h | 22 ++++---- src/stkutil.c | 4 +- 4 files changed, 78 insertions(+), 74 deletions(-)
Here is the summary with links:
- smsutil: Use size_t for lengths and offsets
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=2bdee9065f64
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html