Change in libosmocore[master]: vty: cosmetic: cmd_deopt(): use talloc_strndup(), not memcpy()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Jul 11 13:56:34 UTC 2018


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/9938 )

Change subject: vty: cosmetic: cmd_deopt(): use talloc_strndup(), not memcpy()
......................................................................

vty: cosmetic: cmd_deopt(): use talloc_strndup(), not memcpy()

Change-Id: Ibf870ae02be706f802482f7cff6589a70cde8320
---
M src/vty/command.c
1 file changed, 1 insertion(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/src/vty/command.c b/src/vty/command.c
index 689609c..51dece3 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -1311,18 +1311,11 @@
 	 * match check for "blah"
 	 */
 	size_t len = strlen(str);
-	char *tmp;
 
 	if (len < 3)
 		return NULL;
 
-	/* tmp will hold a string of len-2 chars, so 'len' size is fine */
-	tmp = talloc_size(tall_vty_cmd_ctx, len);
-
-	memcpy(tmp, (str + 1), len - 2);
-	tmp[len - 2] = '\0';
-
-	return tmp;
+	return talloc_strndup(tall_vty_cmd_ctx, str + 1, len - 2);
 }
 
 static enum match_type

-- 
To view, visit https://gerrit.osmocom.org/9938
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf870ae02be706f802482f7cff6589a70cde8320
Gerrit-Change-Number: 9938
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180711/54a53ad8/attachment.htm>


More information about the gerrit-log mailing list