[asterisk-commits] mvanbaak: trunk r135371 - /trunk/channels/chan_skinny.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Aug 2 19:00:07 CDT 2008


Author: mvanbaak
Date: Sat Aug  2 19:00:06 2008
New Revision: 135371

URL: http://svn.digium.com/view/asterisk?view=rev&rev=135371
Log:
Dont coredump on register of non-configured devices

(closes issue #13224)
Reported by: mvanbaak
Patches:
      noncon.diff uploaded by wedhorn (license 30) with whitespace fixes by me
Tested by: wedhorn, mvanbaak

Modified:
    trunk/channels/chan_skinny.c

Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=135371&r1=135370&r2=135371
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Sat Aug  2 19:00:06 2008
@@ -4179,8 +4179,28 @@
 			return -1;
 
 		snprintf(req->data.regrej.errMsg, sizeof(req->data.regrej.errMsg), "No Authority: %s", name);
-		d->session = s;
-		transmit_response(d, req);
+
+		/* transmit_respons in line as we don't have a valid d */
+		ast_mutex_lock(&s->lock);
+
+		if (letohl(req->len > SKINNY_MAX_PACKET) || letohl(req->len < 0)) {
+			ast_log(LOG_WARNING, "transmit_response: the length of the request is out of bounds\n");
+			ast_mutex_unlock(&s->lock);
+			return -1;
+		}
+
+		memset(s->outbuf, 0, sizeof(s->outbuf));
+		memcpy(s->outbuf, req, skinny_header_size);
+		memcpy(s->outbuf+skinny_header_size, &req->data, letohl(req->len));
+
+		res = write(s->fd, s->outbuf, letohl(req->len)+8);
+
+		if (res != letohl(req->len)+8) {
+			ast_log(LOG_WARNING, "Transmit: write only sent %d out of %d bytes: %s\n", res, letohl(req->len)+8, strerror(errno));
+		}
+	
+		ast_mutex_unlock(&s->lock);
+
 		return 0;
 	}
 	ast_verb(3, "Device '%s' successfully registered\n", name);




More information about the asterisk-commits mailing list