1 http://bugzilla.openmoko.org/cgi-bin/bugzilla/show_bug.cgi?id=834
3 From: Kristian Mueller <kristian@mput.de>
4 Subject: [PATCH] libgsmd-tool does not allow sms with more than one word
6 libgsmd-tool only allows for command strings without spaces.
7 SMS messages with more than one word will be parsed as multible commands.
8 The patch introduces SMS message text in bracket and fixes a NULL pointer
9 reference on mailformed "ss" commands.
11 Signed-off-by: Jim Huang <jserv@openmoko.org>
13 src/util/shell.c | 32 ++++++++++++++++++++++++++------
14 1 file changed, 26 insertions(+), 6 deletions(-)
16 Index: gsm/src/util/shell.c
17 ===================================================================
18 --- gsm.orig/src/util/shell.c 2007-08-31 16:15:30.000000000 +0800
19 +++ gsm/src/util/shell.c 2007-09-17 23:35:31.000000000 +0800
21 "\tsd\tSMS Delete (sd=index,delflg)\n"
22 "\tsl\tSMS List (sl=stat)\n"
23 "\tsr\tSMS Read (sr=index)\n"
24 - "\tss\tSMS Send (ss=number,text)\n"
25 + "\tss\tSMS Send (ss=number,text|[\"text\"])\n"
26 "\tsw\tSMS Write (sw=stat,number,text)\n"
27 "\tsm\tSMS Storage stats\n"
28 "\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n"
31 lgsm_sms_read(lgsmh, atoi(ptr+1));
32 } else if ( !strncmp(buf, "ss", 2)) {
33 - printf("Send SMS\n");
36 ptr = strchr(buf, '=');
37 fcomma = strchr(buf, ',');
38 - strncpy(sms.addr, ptr+1, fcomma-ptr-1);
39 - sms.addr[fcomma-ptr-1] = '\0';
40 - packing_7bit_character(fcomma+1, &sms);
41 + if (!ptr || !fcomma) {
42 + printf("Wrong command format\n");
44 + strncpy(sms.addr, ptr+1, fcomma-ptr-1);
45 + sms.addr[fcomma-ptr-1] = '\0';
47 + /* todo define \" to allow " in text */
48 + if (fcomma[1] == '"' &&
49 + !strchr(fcomma+2, '"')) {
50 + /* read until closing '"' */
51 + rc = fscanf(stdin, "%[^\"]\"",
52 + fcomma+strlen(fcomma));
57 + /* remove brackets */
59 + fcomma[strlen(fcomma)] = '\0';
62 + printf("Send SMS\n");
63 + packing_7bit_character(fcomma+1, &sms);
65 - lgsm_sms_send(lgsmh, &sms);
66 + lgsm_sms_send(lgsmh, &sms);
68 } else if ( !strncmp(buf, "sw", 2)) {
69 printf("Write SMS\n");
70 struct lgsm_sms_write sms_write;