From: Matthew Jordan Date: Tue, 29 May 2012 18:33:20 +0000 (+0000) Subject: AST-2012-008: Fix remote crash vulnerability in chan_skinny X-Git-Tag: 10.6.0-rc1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fd6a349f838228c07e5b0cf3d17a4ed51e9cf51;p=thirdparty%2Fasterisk.git AST-2012-008: Fix remote crash vulnerability in chan_skinny When a skinny session is unregistered, the corresponding device pointer is set to NULL in the channel private data. If the client was not in the on-hook state at the time the connection was closed, the device pointer can later be dereferened if a message or channel event attempts to use a line's pointer to said device. The patches prevent this from occurring by checking the line's pointer in message handlers and channel callbacks that can fire after an unregistration attempt. (closes issue ASTERISK-19905) Reported by: Christoph Hebeisen Tested by: mjordan, Damien Wedhorn Patches: AST-2012-008-1.8.diff uploaded by mjordan (license 6283) AST-2012-008-10.diff uploaded by mjordan (licesen 6283) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@367844 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 883c420479..ecd017cd15 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -3104,6 +3104,10 @@ static void update_connectedline(struct skinny_subchannel *sub, const void *data struct skinny_line *l = sub->line; struct skinny_device *d = l->device; + if (!d) { + return; + } + if (!c->caller.id.number.valid || ast_strlen_zero(c->caller.id.number.str) || !c->connected.id.number.valid @@ -4224,6 +4228,11 @@ static void *skinny_ss(void *data) int res = 0; int loop_pause = 100; + if (!d) { + ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name); + return NULL; + } + ast_verb(3, "Starting simple switch on '%s@%s'\n", l->name, d->name); len = strlen(sub->exten); @@ -4332,7 +4341,7 @@ static int skinny_call(struct ast_channel *ast, char *dest, int timeout) struct ast_var_t *current; int doautoanswer = 0; - if (!d->registered) { + if (!d || !d->registered) { ast_log(LOG_ERROR, "Device not registered, cannot call %s\n", dest); return -1; } @@ -4731,7 +4740,13 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s struct skinny_subchannel *sub = ast->tech_pvt; struct skinny_line *l = sub->line; struct skinny_device *d = l->device; - struct skinnysession *s = d->session; + struct skinnysession *s; + + if (!d) { + ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name); + return -1; + } + s = d->session; if (!s) { ast_log(LOG_NOTICE, "Asked to indicate '%s' condition on channel %s, but session does not exist.\n", control2str(ind), ast->name); @@ -5462,6 +5477,11 @@ static int handle_transfer_button(struct skinny_subchannel *sub) l = sub->line; d = l->device; + if (!d) { + ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name); + return -1; + } + if (!sub->related) { /* Another sub has not been created so this must be first XFER press */ if (!(sub->substate == SUBSTATE_HOLD)) { @@ -5506,6 +5526,11 @@ static int handle_callforward_button(struct skinny_subchannel *sub, int cfwdtype struct skinny_device *d = l->device; struct ast_channel *c = sub->owner; + if (!d) { + ast_log(LOG_WARNING, "Device for line %s is not registered.\n", l->name); + return 0; + } + if (d->hookstate == SKINNY_ONHOOK) { d->hookstate = SKINNY_OFFHOOK; transmit_speaker_mode(d, SKINNY_SPEAKERON);