Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 125885
Collapse All | Expand All

(-)yahoo-transport-2.3.2/yahoo.c (-41 / +69 lines)
Lines 261-309 Link Here
261
(((*((buf)+3)    )&0x000000ff)))
261
(((*((buf)+3)    )&0x000000ff)))
262
262
263
static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) {
263
static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len) {
264
    int pos = 0;
264
	int pos = 0;
265
265
266
    while (pos + 1 < len) {
266
	while (pos + 1 < len) {
267
        char key[64], *value = NULL;
267
		char key[64], *value = NULL, *esc;
268
        int accept;
268
		int accept;
269
        int x;
269
		int x;
270
270
271
        struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
271
		struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
272
272
273
        x = 0;
273
		/* this is weird, and in one of the chat packets, and causes us
274
        while (pos + 1 < len) {
274
		 * think all the values are keys and all the keys are values after
275
            if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
275
		 * this point if we don't handle it */
276
                break;
276
		if (data[pos] == '\0') {
277
            key[x++] = data[pos++];
277
			while (pos + 1 < len) {
278
        }
278
				if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
279
        key[x] = 0;
279
					break;
280
        pos += 2;
280
				pos++;
281
        pair->key = strtol(key, NULL, 10);
281
			}
282
        accept = x; /* if x is 0 there was no key, so don't accept it */
282
			pos += 2;
283
			g_free(pair);
284
			continue;
285
		}
283
286
284
        if (accept)
287
		x = 0;
285
            value = g_malloc(len - pos + 1);
288
		while (pos + 1 < len) {
286
        x = 0;
289
			if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
287
        while (pos + 1 < len) {
290
				break;
288
            if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
291
			if (x >= sizeof(key)-1) {
289
                break;
292
				x++;
290
            if (accept)
293
				pos++;
291
                value[x++] = data[pos++];
294
				continue;
292
        }
295
			}
293
        if (pos > len)
296
			key[x++] = data[pos++];
294
            return;
297
		}
295
        if (accept)
298
		if (x >= sizeof(key)-1) {
296
            value[x] = 0;
299
			x = 0;
297
        pos += 2;
300
		}
298
        if (accept) {
301
		key[x] = 0;
299
            pair->value = g_strdup(value);
302
		pos += 2;
300
            g_free(value);
303
		pair->key = strtol(key, NULL, 10);
301
            pkt->hash = g_slist_append(pkt->hash, pair);
304
		accept = x; /* if x is 0 there was no key, so don't accept it */
302
            log_debug(ZONE, "[YAHOO]: Read Key: %d  \tValue: %s\n", pair->key, pair->value);
305
303
        } else {
306
		if (len - pos + 1 <= 0) {
304
            g_free(pair);
307
			/* Truncated. Garbage or something. */
305
        }
308
			accept = 0;
306
    }
309
		}
310
311
		if (accept) {
312
			value = g_malloc(len - pos + 1);
313
			x = 0;
314
			while (pos + 1 < len) {
315
				if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
316
					break;
317
				value[x++] = data[pos++];
318
			}
319
			value[x] = 0;
320
			pair->value = g_strdup(value);
321
			g_free(value);
322
			pkt->hash = g_slist_append(pkt->hash, pair);
323
			esc = g_strescape(pair->value);
324
			log_debug(ZONE, "Read Key: %d  \tValue: %s\n", pair->key, esc);
325
			g_free(esc);
326
		} else {
327
			g_free(pair);
328
		}
329
		pos += 2;
330
331
		/* Skip over garbage we've noticed in the mail notifications */
332
		if (data[0] == '9' && data[pos] == 0x01)
333
			pos++;
334
	}
307
}
335
}
308
336
309
static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) {
337
static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data) {

Return to bug 125885