Change in osmocom-bb[master]: mobile/sms: Simplify the string format routines

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/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Sat Jun 2 11:05:07 UTC 2018


Holger Freyther has uploaded this change for review. ( https://gerrit.osmocom.org/9418


Change subject: mobile/sms: Simplify the string format routines
......................................................................

mobile/sms: Simplify the string format routines

It seems the original code didn't allocate \0 for the string. Just use
talloc_asprintf and get a new string...

Change-Id: I8ffb50b04d2d6196caf0231711f3467abc8c5ea5
---
M src/host/layer23/src/mobile/gsm411_sms.c
1 file changed, 1 insertion(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/18/9418/1

diff --git a/src/host/layer23/src/mobile/gsm411_sms.c b/src/host/layer23/src/mobile/gsm411_sms.c
index 3eca48a..fe13ba1 100644
--- a/src/host/layer23/src/mobile/gsm411_sms.c
+++ b/src/host/layer23/src/mobile/gsm411_sms.c
@@ -182,7 +182,6 @@
 	struct gsm_sms *gsms)
 {
 	const char osmocomsms[] = ".osmocom/bb/sms.txt";
-	int len;
 	const char *home;
 	char *sms_file;
 	char vty_text[sizeof(gsms->text)], *p;
@@ -206,11 +205,9 @@
 			"your home directory.\n", osmocomsms);
 		return GSM411_RP_CAUSE_MT_MEM_EXCEEDED;
 	}
-	len = strlen(home) + 1 + sizeof(osmocomsms);
-	sms_file = talloc_size(l23_ctx, len);
+	sms_file = talloc_asprintf(l23_ctx, "%s/%s", home, osmocomsms);
 	if (!sms_file)
 		goto fail;
-	snprintf(sms_file, len, "%s/%s", home, osmocomsms);
 
 	fp = fopen(sms_file, "a");
 	if (!fp) {

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ffb50b04d2d6196caf0231711f3467abc8c5ea5
Gerrit-Change-Number: 9418
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <holger at freyther.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180602/c1fbdcd2/attachment.htm>


More information about the gerrit-log mailing list