Commit Graph

6 Commits

Author SHA1 Message Date
Pau Espin c63971fab0 Fix Out of bounds compilation warning in OCTET8
The code in OCTET8 implementation assumes the len is placed inside the
byte preceding the memory buffer, which is true for the defined cases.
However, it creates a compilation warning. Better pass the value
directly from the struct field rather than playing addr games. this way
we also assert we require to explicitly pass the len.

Fixes lots of warning like the one below:
/home/pespin/dev/sysmocom/bin/../git/libsmpp34/src/smpp34_unpack.c: In function ‘smpp34_u
npack’:
/home/pespin/dev/sysmocom/bin/../git/libsmpp34/src/smpp34_unpack.c:147:14: warning: array
 subscript is above array bounds [-Warray-bounds]
     lenval = *((inst par) - 1);\
              ^~~~~~~~~~~~~~~~~
/home/pespin/dev/sysmocom/bin/../git/libsmpp34/def_frame/submit_sm.frame:18:2: note: in e
xpansion of macro ‘OCTET8’
  OCTET8( instancia, short_message, 254 );
  ^~~~~~

Change-Id: Id110f4e977c3becdb44cf5492c372e530ea51551
2017-09-15 20:24:25 +02:00
Pau Espin cad0cc552f smpp34_structs.h: Fix truncated output in str_tlv_id
Fixes compilation warning below:

%s’ directive output may be truncated writing between 8 and 33 bytes into a regio
n of size 30 [-Wformat-truncation=]
     snprintf(buff, SMALL_BUFF, "%s",
                                 ^~
/home/pespin/dev/sysmocom/bin/../git/libsmpp34/src/smpp34_params.c:136:5: note: ‘
snprintf’ output between 9 and 34 bytes into a destination of size 30
     snprintf(buff, SMALL_BUFF, "%s",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #define OPERACION( p_tlv_id ) (tlv_id == p_tlv_id)?#p_tlv_id:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #include "def_list/tlv_id.list"
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             "Reserved"
             ~~~~~~~~~~
 #undef OPERACION
 ~~~~~~~~~~~~~~~~
           );

Change-Id: Ie2ba6182eb0cdd98cadb8317aef49141244aa92d
2017-09-15 20:24:20 +02:00
Pau Espin fe9f88add0 smpp34_structs.h: Fix trailing whitespace
Change-Id: I5838e216fe16b4789bb1a0ce40ce496f46a3c328
2017-09-15 20:24:19 +02:00
Pablo Neira Ayuso 9b3cefca21 add smpp34_tlv_for_each() helper
So we don't need to remember this is an opencoded list of TLVs.

Change-Id: I446929feed049d0411e1629ca263e2bc41f714cc
2017-08-11 12:13:54 +02:00
Holger Hans Peter Freyther ef554d0880 const: Make the data parameter for unpack const 2013-09-05 22:43:40 +02:00
Harald Welte 4b233b4f3b initial import of libsmpp34-1.10 2012-11-07 08:32:31 +01:00