Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13901
Change subject: Fix osmo_quote_str_c() for strings larger than 32 bytes ...................................................................... Fix osmo_quote_str_c() for strings larger than 32 bytes As Neels pointed out, we shouldn't pass a constant value of 32 to osmo_quote_str_buf2(). Change-Id: Id9bde14166d6674ce4dda36fa9f4ae9217ce5cc2 --- M src/utils.c 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/01/13901/1 diff --git a/src/utils.c b/src/utils.c index b66721e..e6d9389 100644 --- a/src/utils.c +++ b/src/utils.c @@ -813,10 +813,12 @@ */ char *osmo_quote_str_c(const void *ctx, const char *str, int in_len) { - char *buf = talloc_size(ctx, OSMO_MAX(in_len+2, 32)); + /* some minimum length for things like "NULL" or "(error)" */ + int alloc_size = OSMO_MAX(in_len+2, 32); + char *buf = talloc_size(ctx, alloc_size); if (!buf) return NULL; - return osmo_quote_str_buf2(buf, 32, str, in_len); + return osmo_quote_str_buf2(buf, alloc_size, str, in_len); } /*! perform an integer square root operation on unsigned 32bit integer. -- To view, visit https://gerrit.osmocom.org/13901 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Id9bde14166d6674ce4dda36fa9f4ae9217ce5cc2 Gerrit-Change-Number: 13901 Gerrit-PatchSet: 1 Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>