Mercurial > pidgin
changeset 3996:3fdfe7872118
[gaim-migrate @ 4191]
- Fixed a segfault that occurred when a key/value pair had no value (i.e.,
in the mail notification packets that the Yahoo server is sending out).
- Skip over a garbage character in mail notification packets that's causing
the sender name key/value pair to be ignored.
- Some code cleanups, which should optimize it (though not noticeably so)
and make it easier to read. Thanks go to ZuperDee for this.
Hope this works for everybody else.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 23 Nov 2002 11:08:11 +0000 |
parents | 544e48c05f61 |
children | f6522cd53a80 |
files | src/protocols/yahoo/yahoo.c |
diffstat | 1 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c Fri Nov 22 21:11:39 2002 +0000 +++ b/src/protocols/yahoo/yahoo.c Sat Nov 23 11:08:11 2002 +0000 @@ -268,19 +268,20 @@ pair->key = strtol(key, NULL, 10); accept = x; /* if x is 0 there was no key, so don't accept it */ - if (accept) + if (len - pos + 1 <= 0) { + /* Truncated. Garbage or something. */ + accept = 0; + } + + if (accept) { value = g_malloc(len - pos + 1); - x = 0; - while (pos + 1 < len) { - if (data[pos] == 0xc0 && data[pos + 1] == 0x80) - break; - if (accept) + x = 0; + while (pos + 1 < len) { + if (data[pos] == 0xc0 && data[pos + 1] == 0x80) + break; value[x++] = data[pos++]; - } - if (accept) + } value[x] = 0; - pos += 2; - if (accept) { pair->value = g_strdup(value); g_free(value); pkt->hash = g_slist_append(pkt->hash, pair); @@ -288,6 +289,11 @@ } else { g_free(pair); } + pos += 2; + + /* Skip over garbage we've noticed in the mail notifications */ + if (data[0] == '9' && data[pos] == 0x01) + pos++; } }