libosmocore/src
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
..
codec codec/ecu: Introduce new generic Error Concealment Unit abstraction 2019-09-02 09:13:50 +00:00
coding osmo-release.sh: Drop whitespace after = when parsing LIBVERSION 2019-08-06 17:58:28 +02:00
ctrl Bump version: 1.1.0.107-afce-dirty → 1.2.0 2019-08-06 18:02:02 +02:00
gb GPRS/BSSGP: introduce bssgp_bvc_ctx_free() 2019-11-09 02:14:50 +07:00
gsm GSUP: rename E_ROUTING_ERROR to ROUTING_ERROR 2019-11-24 19:58:57 +01:00
pseudotalloc pseudotalloc: Simplistic wrapper of talloc_named() 2019-07-31 10:16:07 +02:00
sim sim/class_tables: Fix typo in comment 2019-09-28 13:00:48 +02:00
vty vty: track parent nodes also for telnet sessions 2019-11-24 19:59:35 +01:00
Makefile.am socket: Introduce API osmo_sock_init2_multiaddr() 2019-10-18 09:21:48 +00:00
application.c application.c: drop wrong \references of osmo_init_ignore_signals() 2019-04-25 02:23:52 +07:00
backtrace.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bitcomp.c bitcomp.c: fix missing Doxygen group closing tag 2019-04-25 02:23:52 +07:00
bits.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bitvec.c bitvec/bitval2mask(): cosmetic: get rid of temporary int variable 2019-07-18 09:07:53 +00:00
context.c context: Add support for [per-thread] global talloc contexts 2019-08-27 13:43:31 +02:00
conv.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
conv_acc.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_generic.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
conv_acc_sse.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_sse_avx.c conv_acc: Our code requires SSSE3, not just SSE3 2017-11-17 11:44:22 +01:00
conv_acc_sse_impl.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
counter.c counters: add osmo_counters_count() returns the amount of counters 2017-12-05 16:06:27 +01:00
crc16.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
crcXXgen.c.tpl Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
fsm.c fsm: refuse state chg and events after term 2019-10-29 17:28:30 +01:00
gsmtap_util.c src/gsmtap_util.c: fix possible memleak in gsmtap_source_init() 2019-03-28 10:07:59 +00:00
isdnhdlc.c isdnhdlc: Port from kernel to userspace 2018-05-11 21:57:46 +02:00
logging.c fix DLSMS logging category color: '[1:38m' isn't actually defined 2019-11-23 07:58:47 +00:00
logging_gsmtap.c logging_gsmtap.c: document all params of log_target_create_gsmtap() 2019-03-27 08:56:21 +01:00
logging_syslog.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
loggingrb.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
macaddr.c osmo_get_macaddr: Fix buffer read out of bounds 2018-04-18 08:57:56 +00:00
msgb.c make all library-internal static buffers thread-local 2019-06-04 10:47:30 +02:00
msgfile.c memleak: osmo_config_list_parse: getline() needs free also on error 2017-11-18 10:30:57 +00:00
panic.c osmo_panic(): Annotate as __attribute__ ((noreturn)) 2018-06-29 20:32:57 +02:00
plugin.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
prbs.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
prim.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
rate_ctr.c Revert "Print error message if application fails to call rate_ctr_init()" 2019-05-10 11:52:58 +02:00
rbtree.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
select.c select: Make file descriptor lists per-thread 2019-11-07 10:24:50 +01:00
sercomm.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
serial.c cosmetic: clarify c_iflag in osmo_serial_init() 2019-09-28 13:00:48 +02:00
signal.c Revert "signal.c: Make non-exported tall_sigh_ctx static" 2019-03-22 13:25:01 +01:00
sockaddr_str.c osmo_sockaddr_str: deprecate osmo_sockaddr_str_*_32n() 2019-11-24 19:59:35 +01:00
socket.c socket.c: build multiaddr socket API helpers only if used by public APIs 2019-10-24 15:39:27 +02:00
stat_item.c add osmo_stat_item_inc/osmo_stat_item_dec to set it relative 2019-05-07 13:20:57 +00:00
stats.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
stats_statsd.c stats_statsd: Send all stat_items as gauges 2018-10-24 16:37:05 +02:00
strrb.c Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
tdef.c tdef: Return correct snprintf value for osmo_tdef_range_str_buf() 2019-10-18 09:20:58 +00:00
timer.c Doxygen: fix documentation of osmo_timer_setup() 2019-03-27 08:56:21 +01:00
timer_clockgettime.c Fix embedded (arm-none-eabi) builds 2018-06-28 10:30:34 +02:00
timer_gettimeofday.c timer: Document osmo_gettimeofday API 2018-03-01 12:33:03 +00:00
use_count.c add osmo_use_count API 2019-04-08 13:47:17 +00:00
utils.c add osmo_escape_cstr and osmo_quote_cstr 2019-11-24 19:59:35 +01:00
write_queue.c select: Rename BSC_FD_* constants to OSMO_FD_* 2019-03-21 16:02:01 +00:00