diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-06-02 11:14:51 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-06-02 11:14:51 +0800 |
commit | a81c83fc2cd9ef04167a499011315878281afd2e (patch) | |
tree | 833f6211c89fae0c0ceaba53cf144c8b50dc8ea8 | |
parent | 61fe379446a70946ac9da417042a5177ac5dac96 (diff) |
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
-rw-r--r-- | src/host/layer23/src/mobile/gsm411_sms.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/host/layer23/src/mobile/gsm411_sms.c b/src/host/layer23/src/mobile/gsm411_sms.c index 3eca48a9..fe13ba1b 100644 --- a/src/host/layer23/src/mobile/gsm411_sms.c +++ b/src/host/layer23/src/mobile/gsm411_sms.c @@ -182,7 +182,6 @@ static int gsm340_rx_sms_deliver(struct osmocom_ms *ms, struct msgb *msg, 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 @@ fail: "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) { |