diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2017-11-16 23:34:33 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2017-11-20 17:22:42 +0100 |
commit | e750980d6c89cf7052daa62745366a743badd384 (patch) | |
tree | f5272afa43be1b91f351fff20e565b5e34481143 /src/gsm/gsm0808.c | |
parent | 85f5a2cd9c46ffd165f9244b4e219bfc03aa5e0e (diff) |
tlv_put: guard against NULL val and 0 len
For example encode_auth_info() from gsup.c calls
msgb_tlv_put(msg, iei, 0, NULL)
to put a tag and len with content data following later.
However, this would cause a memcpy() from a NULL pointer, in tlv_put(). Allow
passing NULL and len = 0 for cases like the above:
If val is NULL, use memset(0) instead of memcpy().
If len is zero, do not copy nor memset anything.
Hence make tlv_put() behave in a well-defined and valid way for any and all
input args; no negative fallout is possible from this patch.
Add proper API doc comment.
Fixes a sanitizer build failure in gsup_test:
../../../../src/libosmocore/include/osmocom/gsm/tlv.h:99:2: runtime error: null pointer passed as argument 2, which is declared to never be null
Helps fix sanitizer build on debian 9.
Change-Id: I13dce9cd1228817890d3e81edeeb660c893c1d64
Diffstat (limited to 'src/gsm/gsm0808.c')
0 files changed, 0 insertions, 0 deletions