mirror of git://git.sysmocom.de/ofono
handsfree-audio: Add codec array validation
This patch checks if the codec array included in the "Register" method contains valid codec ID's.
This commit is contained in:
parent
16246e120e
commit
9b77d65bf9
|
@ -32,6 +32,12 @@
|
||||||
|
|
||||||
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
|
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
|
||||||
|
|
||||||
|
/* Supported agent codecs */
|
||||||
|
enum hfp_codec {
|
||||||
|
HFP_CODEC_CVSD = 0x01,
|
||||||
|
HFP_CODEC_MSBC = 0x02,
|
||||||
|
};
|
||||||
|
|
||||||
struct agent {
|
struct agent {
|
||||||
char *owner;
|
char *owner;
|
||||||
char *path;
|
char *path;
|
||||||
|
@ -53,7 +59,7 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
|
||||||
const char *sender, *path;
|
const char *sender, *path;
|
||||||
unsigned char *codecs;
|
unsigned char *codecs;
|
||||||
DBusMessageIter iter, array;
|
DBusMessageIter iter, array;
|
||||||
int length;
|
int length, i;
|
||||||
|
|
||||||
if (agent)
|
if (agent)
|
||||||
return __ofono_error_in_use(msg);
|
return __ofono_error_in_use(msg);
|
||||||
|
@ -72,6 +78,12 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return __ofono_error_invalid_args(msg);
|
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 = g_new0(struct agent, 1);
|
||||||
agent->owner = g_strdup(sender);
|
agent->owner = g_strdup(sender);
|
||||||
agent->path = g_strdup(path);
|
agent->path = g_strdup(path);
|
||||||
|
|
Loading…
Reference in New Issue