diff options
author | Andrzej Zaborowski <andrew.zaborowski@intel.com> | 2010-10-25 07:51:25 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-10-25 17:20:17 -0500 |
commit | e0663bd0eda7ed7a8141bcf3aa9c41053572ca7c (patch) | |
tree | 975fd561baba53bcdeab0fc6b376ca6caca254d3 | |
parent | ee4879d19689957c729317c7c02ae34fd9e1160f (diff) | |
download | ofono-e0663bd0eda7ed7a8141bcf3aa9c41053572ca7c.tar.bz2 |
voicecall: Limit tone string length per request.
Also change to avoid memcpying into a buffer.
-rw-r--r-- | src/voicecall.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/voicecall.c b/src/voicecall.c index 26cfb9a8..bd644326 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -2472,7 +2472,7 @@ static gboolean tone_request_run(gpointer user_data) { struct ofono_voicecall *vc = user_data; struct tone_queue_entry *entry = g_queue_peek_head(vc->toneq); - char buf[256]; + char final; unsigned len; vc->tone_source = 0; @@ -2483,14 +2483,17 @@ static gboolean tone_request_run(gpointer user_data) len = strcspn(entry->left, "pP"); if (len) { - if (len >= sizeof(buf)) - len = sizeof(buf) - 1; + if (len > 8) /* Arbitrary length limit per request */ + len = 8; - memcpy(buf, entry->left, len); - buf[len] = '\0'; - entry->left += len; + /* Temporarily move the end of the string */ + final = entry->left[len]; + entry->left[len] = '\0'; + + vc->driver->send_tones(vc, entry->left, tone_request_cb, vc); - vc->driver->send_tones(vc, buf, tone_request_cb, vc); + entry->left += len; + entry->left[0] = final; } else tone_request_cb(NULL, vc); |