diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-11-20 21:57:32 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2019-11-23 07:58:47 +0000 |
commit | c36e2e4924eaf573e6a02573259699771dbeab2d (patch) | |
tree | 8f7b9fa110293fd4523eda33526ca07d5ebc157c /src/gsm | |
parent | 823073aa911bbc218804774e6bfe9ad80310596c (diff) |
fix osmo_escape_str_c() and osmo_quote_str_c()
The osmo_escape_str_c() and osmo_quote_str_c() functions return truncated
results when characters need escaping. For example:
osmo_quote_str_c(NULL, "foo"); --> "foo"
osmo_quote_str_c(NULL, "foo\n"); --> "foo\n
osmo_quote_str_c(NULL, "foo\tbar\t\n"); --> "foo\tbar\t
Implement these _c variants using OSMO_NAME_C_IMPL() to always allocate
sufficient memory.
However, current osmo_escape_str_buf2() and osmo_quote_str_buf2() fail to
return the required buffer size (even though that information is readily
avaiable), so these don't qualify for accurate use of OSMO_NAME_C_IMPL().
Hence, move the implementations of osmo_escape_str and osmo_quote_str to an
internal static function that returns the characters needed, so that all
dynamically allocating implementations can return un-truncated results.
Of course, external callers would also benefit from escape/quote API that
accurately returns the amount of characters needed, but I am not changing
public API in this patch, on purpose, ... yet.
Change-Id: I16c08eced41bf1b7acf6e95f658068ace99ca4c8
Diffstat (limited to 'src/gsm')
0 files changed, 0 insertions, 0 deletions