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
Mon Jul 9 22:02:29 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/9938/1

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: newchange
Gerrit-Change-Id: Ibf870ae02be706f802482f7cff6589a70cde8320
Gerrit-Change-Number: 9938
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180709/851a76b7/attachment.htm>


More information about the gerrit-log mailing list