libosmocore/include/osmocom/gsm
Neels Hofmeyr e750980d6c 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
2017-11-20 17:22:42 +01:00
..
protocol add osmo_imsi_str_valid() and osmo_msisdn_str_valid() 2017-10-05 19:44:28 +02:00
a5.h [doc] gea has separate group; A5 is not part of crypto but a5 group 2017-10-17 07:53:02 +02:00
abis_nm.h abis_nm: Add abis_nm_admin_name() API 2017-10-23 16:59:57 +00:00
apn.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
bitvec_gsm.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
comp128.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
comp128v23.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gan.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gea.h [doc] gea has separate group; A5 is not part of crypto but a5 group 2017-10-17 07:53:02 +02:00
gsm48.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gsm48_ie.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gsm0341.h [doc] make sure all SMS related code is part of the 'sms' group 2017-10-17 07:53:02 +02:00
gsm0411_smc.h [doc] make sure all SMS related code is part of the 'sms' group 2017-10-17 07:53:02 +02:00
gsm0411_smr.h [doc] make sure all SMS related code is part of the 'sms' group 2017-10-17 07:53:02 +02:00
gsm0411_utils.h [doc] make sure all SMS related code is part of the 'sms' group 2017-10-17 07:53:02 +02:00
gsm0480.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gsm0502.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
gsm0808.h [doc] Properly define gsm0800 group and move all related files into it 2017-10-17 07:53:02 +02:00
gsm0808_utils.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
gsm23003.h add osmo_imsi_str_valid() and osmo_msisdn_str_valid() 2017-10-05 19:44:28 +02:00
gsm_utils.h Add function to generate random identifier 2017-10-09 10:18:07 +00:00
gsup.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
ipa.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
kasumi.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
l1sap.h l1sap.h: Add ber10k and lqual_cb to ph_tch_param 2017-06-30 12:06:06 +02:00
lapd_core.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
lapdm.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
meas_rep.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
mncc.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
oap.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
prim.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
rsl.h [doc] Rename "RSL" to "A-bis RSL" in documentation. 2017-10-16 15:32:06 +02:00
rxlev_stat.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
sysinfo.h extend osmo_sysinfo_type with missing SYSINFO_TYPE 2017-07-15 22:49:19 +02:00
tlv.h tlv_put: guard against NULL val and 0 len 2017-11-20 17:22:42 +01:00