summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorjserv <jserv@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-10-17 04:30:24 +0000
committerjserv <jserv@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-10-17 04:30:24 +0000
commit370e88780fd9caf011bbfe79fe8f99810a34bf96 (patch)
tree3d0b877181f1e564cc4f35dceb1cce5f94cf784c /src/util
parentd5cbcad65ca488fe933041b53fc1f71b9bfa3a35 (diff)
http://bugzilla.openmoko.org/cgi-bin/bugzilla/show_bug.cgi?id=834
From: Kristian Mueller <kristian@mput.de> Subject: [PATCH] libgsmd-tool does not allow sms with more than one word libgsmd-tool only allows for command strings without spaces. SMS messages with more than one word will be parsed as multible commands. The patch introduces SMS message text in bracket and fixes a NULL pointer reference on mailformed "ss" commands. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3199 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/util')
-rw-r--r--src/util/shell.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/util/shell.c b/src/util/shell.c
index ae07afc..63261ad 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -389,7 +389,7 @@ static int shell_help(void)
"\tsd\tSMS Delete (sd=index,delflg)\n"
"\tsl\tSMS List (sl=stat)\n"
"\tsr\tSMS Read (sr=index)\n"
- "\tss\tSMS Send (ss=number,text)\n"
+ "\tss\tSMS Send (ss=number,text|[\"text\"])\n"
"\tsw\tSMS Write (sw=stat,number,text)\n"
"\tsm\tSMS Storage stats\n"
"\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n"
@@ -612,16 +612,36 @@ int shell_main(struct lgsm_handle *lgsmh)
lgsm_sms_read(lgsmh, atoi(ptr+1));
} else if ( !strncmp(buf, "ss", 2)) {
- printf("Send SMS\n");
struct lgsm_sms sms;
ptr = strchr(buf, '=');
fcomma = strchr(buf, ',');
- strncpy(sms.addr, ptr+1, fcomma-ptr-1);
- sms.addr[fcomma-ptr-1] = '\0';
- packing_7bit_character(fcomma+1, &sms);
+ if (!ptr || !fcomma) {
+ printf("Wrong command format\n");
+ } else {
+ strncpy(sms.addr, ptr+1, fcomma-ptr-1);
+ sms.addr[fcomma-ptr-1] = '\0';
+
+ /* todo define \" to allow " in text */
+ if (fcomma[1] == '"' &&
+ !strchr(fcomma+2, '"')) {
+ /* read until closing '"' */
+ rc = fscanf(stdin, "%[^\"]\"",
+ fcomma+strlen(fcomma));
+ if (rc == EOF) {
+ printf("EOF\n");
+ return -1;
+ }
+ /* remove brackets */
+ fcomma++;
+ fcomma[strlen(fcomma)] = '\0';
+ }
+
+ printf("Send SMS\n");
+ packing_7bit_character(fcomma+1, &sms);
- lgsm_sms_send(lgsmh, &sms);
+ lgsm_sms_send(lgsmh, &sms);
+ }
} else if ( !strncmp(buf, "sw", 2)) {
printf("Write SMS\n");
struct lgsm_sms_write sms_write;
personal git repositories of Harald Welte. Your mileage may vary