From ca27aa8f9d91d68bfd55fb17fea181a1ba6054a4 Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Mon, 18 Nov 2013 00:03:53 +0100 Subject: Better error checking on session metadata --- session.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'session.c') diff --git a/session.c b/session.c index 109ede1..7eeab16 100644 --- a/session.c +++ b/session.c @@ -170,10 +170,27 @@ SRD_API int srd_session_metadata_set(struct srd_session *sess, int key, return SRD_ERR_ARG; } + if (!key) { + srd_err("Invalid key."); + return SRD_ERR_ARG; + } + + if (!data) { + srd_err("Invalid value."); + return SRD_ERR_ARG; + } + + /* Hardcoded to samplerate/uint64 for now. */ + if (key != SRD_CONF_SAMPLERATE) { srd_err("Unknown config key %d.", key); return SRD_ERR_ARG; } + if (!g_variant_is_of_type(data, G_VARIANT_TYPE_UINT64)) { + srd_err("Invalid value type: expected uint64, got %s", + g_variant_get_type_string(data)); + return SRD_ERR_ARG; + } srd_dbg("Setting session %d samplerate to %"PRIu64".", sess->session_id, g_variant_get_uint64(data)); -- cgit v1.2.3-70-g09d2