[svn-commits] seanbright: trunk r198375 - /trunk/res/res_jabber.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sat May 30 15:11:38 CDT 2009
Author: seanbright
Date: Sat May 30 15:11:33 2009
New Revision: 198375
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=198375
Log:
Properly terminate the receive buffer before sending to iksemel.
aji_io_recv takes the maximum number of bytes to read (instead of the total
buffer size), so we have to subtract 1 from our buffer size. Without this, when
we receive packets that are larger than our buffer, iksemel will choke and
things get wonky.
(closes issue #15232)
Reported by: lp0
Patches:
05302009_res_jabber.c.patch uploaded by seanbright (license 71)
Tested by: seanbright, lp0
Modified:
trunk/res/res_jabber.c
Modified: trunk/res/res_jabber.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/res/res_jabber.c?view=diff&rev=198375&r1=198374&r2=198375
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Sat May 30 15:11:33 2009
@@ -723,8 +723,8 @@
static int aji_recv (struct aji_client *client, int timeout)
{
int len, ret;
- char buf[NET_IO_BUF_SIZE -1];
- char newbuf[NET_IO_BUF_SIZE -1];
+ char buf[NET_IO_BUF_SIZE - 1];
+ char newbuf[NET_IO_BUF_SIZE - 1];
int pos = 0;
int newbufpos = 0;
unsigned char c;
@@ -733,7 +733,7 @@
memset(newbuf, 0, sizeof(newbuf));
while (1) {
- len = aji_io_recv(client, buf, NET_IO_BUF_SIZE - 1, timeout);
+ len = aji_io_recv(client, buf, NET_IO_BUF_SIZE - 2, timeout);
if (len < 0) return IKS_NET_RWERR;
if (len == 0) return IKS_NET_EXPIRED;
buf[len] = '\0';
@@ -766,8 +766,18 @@
ret = iks_parse(client->p, newbuf, 0, 0);
memset(newbuf, 0, sizeof(newbuf));
+ switch (ret) {
+ case IKS_NOMEM:
+ ast_log(LOG_WARNING, "Parsing failure: Out of memory.\n");
+ break;
+ case IKS_BADXML:
+ ast_log(LOG_WARNING, "Parsing failure: Invalid XML.\n");
+ break;
+ case IKS_HOOK:
+ ast_log(LOG_WARNING, "Parsing failure: Hook returned an error.\n");
+ break;
+ }
if (ret != IKS_OK) {
- ast_log(LOG_WARNING, "XML parsing failed\n");
return ret;
}
ast_debug(3, "XML parsing successful\n");
More information about the svn-commits
mailing list