summaryrefslogtreecommitdiffstats
path: root/src/handsfree-audio.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2013-02-20 18:55:47 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-20 21:22:45 -0600
commit9b77d65bf9d6d08ec58b0769faab5cb60d059e65 (patch)
tree8ad791b293a289d66e7b961e54c9da089fbe6268 /src/handsfree-audio.c
parent16246e120e9c856999e46b2c1961c1f278835063 (diff)
downloadofono-9b77d65bf9d6d08ec58b0769faab5cb60d059e65.tar.bz2
handsfree-audio: Add codec array validation
This patch checks if the codec array included in the "Register" method contains valid codec ID's.
Diffstat (limited to 'src/handsfree-audio.c')
-rw-r--r--src/handsfree-audio.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index ee67f05e..499e0ded 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -32,6 +32,12 @@
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
+/* Supported agent codecs */
+enum hfp_codec {
+ HFP_CODEC_CVSD = 0x01,
+ HFP_CODEC_MSBC = 0x02,
+};
+
struct agent {
char *owner;
char *path;
@@ -53,7 +59,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
const char *sender, *path;
unsigned char *codecs;
DBusMessageIter iter, array;
- int length;
+ int length, i;
if (agent)
return __ofono_error_in_use(msg);
@@ -72,6 +78,12 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
if (length == 0)
return __ofono_error_invalid_args(msg);
+ for (i = 0; i < length; i++) {
+ if (codecs[i] != HFP_CODEC_CVSD &&
+ codecs[i] != HFP_CODEC_MSBC)
+ return __ofono_error_invalid_args(msg);
+ }
+
agent = g_new0(struct agent, 1);
agent->owner = g_strdup(sender);
agent->path = g_strdup(path);