libosmocore/tests
Neels Hofmeyr 8a7eed50db add osmo_escape_cstr and osmo_quote_cstr
Provide string escaping that
- returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND().
- uses C compatible string constant escaping sequences.

This is intended as a replacement for all previous osmo_escape_str* and
osmo_quote_str* API. It pains me that I didn't get them right the first nor the
second time:
- The buffer functions do not return the chars needed, which is required for
  allocating sufficient memory in the *_c versions of the functions.
- Because of that, these functions are accurately usable for
  OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a
  GSUP message.
- They do not use the C equivalent string constant escaping: for some reason I
  thought "\15" would be valid, but it should be "\x0f".
If I could, I would completely drop those mislead implementations ... but
backwards compat prohibits that.

A previous patch already provided internal static functions that accurately
return the required buffer size. Enhance these to also support C compatible
string escaping, and use them as implementation of the new functions:

osmo_escape_cstr_buf()
osmo_escape_cstr_c()
osmo_quote_cstr_buf()
osmo_quote_cstr_c()

In the tests for these, also test C string equivalence.

Naming: from API versions, it would be kind of logical to call them
osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a
different escaping, it makes sense to me to have distinct names instead.

Quasi missing are variants of the non-C-compatible weird legacy escaping that
return the required buffer size, but I refrain from adding those, because we
have enough API cruft as it is. Just always use these new cstr variants.

Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-24 19:59:35 +01:00
..
a5 tests: a5_test: Print wrong buffer correctly on error 2018-05-16 21:13:58 +02:00
abis use osmo_init_logging2() with proper talloc ctx 2018-04-06 04:37:50 +02:00
auth Use define for key buffers 2018-12-20 09:51:02 +00:00
bits tests: bitrev_test: Fix dynamic-stack-buffer-overflow 2018-05-16 17:10:33 +02:00
bitvec bitvec: Add bitvec_tailroom_bits() function 2019-02-05 11:16:44 +01:00
codec ecu_fr: increase test coverage for FR ECU implementation 2019-09-20 11:21:46 +02:00
coding coding: check gsm0503_rach_*() results 2019-03-05 11:30:39 +01:00
comp128 tests: test actual support status for auth. algo 2016-06-29 16:33:40 +00:00
context context: Add support for [per-thread] global talloc contexts 2019-08-27 13:43:31 +02:00
conv Add functions for extended RACH coding 2017-12-11 10:36:47 +00:00
ctrl utils.h: require a semi colon after OSMO_ASSERT 2019-07-08 13:23:45 +00:00
endian add/clean big-endian packed structs (struct_endianess.py) 2018-12-19 18:40:03 +00:00
fr license: Fix the license to GPL 2017-12-09 13:03:29 +00:00
fsm fsm: refuse state chg and events after term 2019-10-29 17:28:30 +01:00
gb NS: Factor out gprs_nsvc_start_test() and use it 2019-02-26 12:18:30 +01:00
gea tests: gea_test: Use correct max size for key in buffer 2018-05-16 20:09:39 +02:00
gprs use osmo_init_logging2() with proper talloc ctx 2018-04-06 04:37:50 +02:00
gsm0408 gsm: gsm_utils: Fix return type of API ms_class_gmsk_dbm() and add unit tests 2019-11-04 12:41:22 +01:00
gsm0502 gsm0508: add functions to calculate beginning of a block 2019-10-28 19:43:14 +00:00
gsm0808 gsm0808_test: Fix wrong use of memcp 2019-07-30 12:51:29 +00:00
gsm23003 gsm23003: add osmo_imei_str_valid() 2019-01-14 14:39:57 +00:00
gsm29205 gsm29205_test: fix error: missing braces around initializer 2019-09-27 03:16:17 +00:00
gsup gsup: add OSMO_GSUP_SUPPORTED_RAT_TYPES_IE and OSMO_GSUP_CURRENT_RAT_TYPE_IE 2019-09-28 14:34:07 +02:00
kasumi gsm: kasumi: Fix dynamic-stack-buffer-overflow on out buffers not multiple of 64 bits 2018-05-17 12:13:04 +02:00
lapd RSL/LAPDm: Not all RLL message are "transparent" 2018-04-19 15:09:32 +00:00
logging logging.h: define ansi color constants 2019-11-23 07:58:47 +00:00
loggingrb logging.h: define ansi color constants 2019-11-23 07:58:47 +00:00
msgb use osmo_init_logging2() with proper talloc ctx 2018-04-06 04:37:50 +02:00
msgfile build: resolve compiler warning about implicit delcaration 2014-10-04 11:49:23 +02:00
oap oap_client: Fix license: GPLv2+ instead of AGPLv3+ 2019-05-27 23:26:45 +02:00
osmo-auc-gen umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-gen 2017-08-29 12:46:46 +00:00
prbs Add pseudo-random bit sequence generator to libosmcoore 2017-07-10 23:42:02 +02:00
sercomm Embedded: add sercomm stubs 2018-01-21 19:08:05 +00:00
sim sim: Fix compiler warning and by this fixing the test result 2016-03-21 11:29:16 +01:00
sms use osmo_init_logging2() with proper talloc ctx 2018-04-06 04:37:50 +02:00
smscb test: Fix compiler warnings on 64bit systems 2015-11-09 16:46:03 +00:00
sockaddr_str osmo_sockaddr_str: deprecate osmo_sockaddr_str_*_32n() 2019-11-24 19:59:35 +01:00
socket use osmo_init_logging2() with proper talloc ctx 2018-04-06 04:37:50 +02:00
stats add osmo_stat_item_inc/osmo_stat_item_dec to set it relative 2019-05-07 13:20:57 +00:00
strrb Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
tdef tdef_test: verify case where osmo_tdef_set returns -EEXIST 2019-10-07 13:14:14 +00:00
timer timer: Introduce osmo_clock_gettime to override clock_gettime 2018-03-01 12:33:02 +00:00
tlv TLV: Add one-shot TLV encoder 2019-05-19 07:33:32 +00:00
use_count add osmo_use_count API 2019-04-08 13:47:17 +00:00
ussd gsm/gsm0480: refactor and expose gsm0480_parse_facility_ie() 2018-06-11 23:50:00 +07:00
utils add osmo_escape_cstr and osmo_quote_cstr 2019-11-24 19:59:35 +01:00
vty vty: track parent nodes also for telnet sessions 2019-11-24 19:59:35 +01:00
write_queue wqueue: Reject messges if queue is considered full 2016-12-09 11:37:37 +01:00
Makefile.am logging/vty: fix: actually ignore deprecated logging commands 2019-11-21 10:48:02 +07:00
atlocal.in build: make check: disable sim_test when built with --disable-pcsc 2016-11-16 16:40:44 +00:00
libsercomstub.c Embedded: add sercomm stubs 2018-01-21 19:08:05 +00:00
testsuite.at logging/vty: fix vty_read_file(): do not write warnings to stdin 2019-11-21 10:48:30 +07:00