diff options
author | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-30 20:19:27 +0000 |
---|---|---|
committer | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-30 20:19:27 +0000 |
commit | e0bcd38fa16f59bd40f518ec9b52f7a4e83409aa (patch) | |
tree | fd847faff6091defe699135decc95537977b6c41 /res | |
parent | 2f1379365c621f9ae66089a097e75f29c7f9032f (diff) |
Merged revisions 198375 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r198375 | seanbright | 2009-05-30 16:11:33 -0400 (Sat, 30 May 2009) | 13 lines
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
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@198384 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_jabber.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c index e54be0bfa..543dd909b 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -645,8 +645,8 @@ static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, 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; @@ -655,7 +655,7 @@ static int aji_recv (struct aji_client *client, int timeout) 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'; @@ -688,8 +688,18 @@ static int aji_recv (struct aji_client *client, int timeout) 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"); |