Mercurial > pidgin.yaz
comparison libgaim/protocols/yahoo/yahoo_packet.c @ 15222:3043806ad900
[gaim-migrate @ 18011]
I think this'll fix an occasional "invalid read of size 1 bytes"
message from valgrind. I'm not sure when it happens... it seems
like it would only happen for invalid packets (ones that don't
end in 0xc0 80 or whatever it is)
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 17 Dec 2006 04:55:12 +0000 |
parents | 74511b8e9b46 |
children |
comparison
equal
deleted
inserted
replaced
15221:152756b02fca | 15222:3043806ad900 |
---|---|
153 key[x] = 0; | 153 key[x] = 0; |
154 pos += 2; | 154 pos += 2; |
155 pair->key = strtol(key, NULL, 10); | 155 pair->key = strtol(key, NULL, 10); |
156 accept = x; /* if x is 0 there was no key, so don't accept it */ | 156 accept = x; /* if x is 0 there was no key, so don't accept it */ |
157 | 157 |
158 if (pos > len) { | 158 if (pos + 1 > len) { |
159 /* Truncated. Garbage or something. */ | 159 /* Malformed packet! (Truncated--garbage or something) */ |
160 accept = FALSE; | 160 accept = FALSE; |
161 } | 161 } |
162 | 162 |
163 if (accept) { | 163 if (accept) { |
164 delimiter = (const guchar *)strstr((char *)&data[pos], "\xc0\x80"); | 164 delimiter = (const guchar *)strstr((char *)&data[pos], "\xc0\x80"); |
165 if (delimiter == NULL) | 165 if (delimiter == NULL) |
166 { | 166 { |
167 /* Malformed packet! (it doesn't end in 0xc0 0x80) */ | 167 /* Malformed packet! (It doesn't end in 0xc0 0x80) */ |
168 g_free(pair); | 168 g_free(pair); |
169 pos = len; | 169 pos = len; |
170 continue; | 170 continue; |
171 } | 171 } |
172 x = delimiter - data; | 172 x = delimiter - data; |