Holger Freyther has submitted this change and it was merged. ( 
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(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



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: merged
Gerrit-Change-Id: I8ffb50b04d2d6196caf0231711f3467abc8c5ea5
Gerrit-Change-Number: 9418
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Holger Freyther <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to