From 35648353ff877344d577e9247ee6f8cfa15ed940 Mon Sep 17 00:00:00 2001 From: Marius Halden Date: Thu, 28 Jan 2016 04:14:06 +0100 Subject: Better error checking --- protocols/twitter/twitter.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'protocols/twitter/twitter.c') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 2cac166f..76625b3d 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -317,7 +317,7 @@ struct groupchat *twitter_groupchat_init(struct im_connection *ic) tmp = set_getstr(&ic->acc->set, "channel_name"); - if (tmp == NULL) { + if (tmp == NULL || strlen(tmp) == 0) { name_hint = g_strdup_printf("%s_%s", td->prefix, ic->acc->user); } else { name_hint = g_strdup(tmp); @@ -527,7 +527,19 @@ static char *set_eval_commands(set_t * set, char *value) static char *set_eval_channel_name(set_t * set, char *value) { - return value; // XXX: Validate somethig here? + size_t len; + + if (value == NULL) { + return NULL; + } + + len = strlen(value); + + if (len < MAX_NICK_LENGTH && len > 0) { + return value; + } else { + return NULL; + } } static char *set_eval_mode(set_t * set, char *value) -- cgit v1.2.3