Change in libosmocore[master]: Fix osmo_quote_str_c() for strings larger than 32 bytes

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue May 7 14:54:55 UTC 2019


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 <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190507/6625fb90/attachment.html>


More information about the gerrit-log mailing list