diff options
author | dequis <dx@dxzone.com.ar> | 2014-11-24 02:16:09 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2014-11-24 02:16:09 -0300 |
commit | b38d399811a556b07a088ec05b947e56397e557b (patch) | |
tree | 2a7996e3f726f7403d8f626119d0d015ea1290bc /protocols/yahoo/libyahoo2.c | |
parent | e2472ddb562e9118ed607b5938c7797af6a79e0c (diff) |
Use glib functions for base64 decoding/encoding
This fixes several coverity warnings about 'tainted data index sink' and
a fixme about thread safety in the old base64_decode implementation.
Had to adapt the code that used base64_encode_real:
- oauth.c: different character set order, but it's for the nonce so it
doesn't matter
- libyahoo2.c: used as part of the auth, changes "+/=" into "._-".
Fixed by encoding first the usual way through glib, then replacing.
Diffstat (limited to 'protocols/yahoo/libyahoo2.c')
-rw-r--r-- | protocols/yahoo/libyahoo2.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 972ee134..fe40786b 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -680,10 +680,25 @@ static void yahoo_packet_dump(unsigned char *data, int len) } } -/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ +/* yahoo's variant of base64 */ static void to_y64(unsigned char *out, const unsigned char *in, int inlen) { - base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); + char *encoded = base64_encode(in, inlen); + int i = 0; + + do { + if (encoded[i] == '+') { + out[i] = '.'; + } else if (encoded[i] == '/') { + out[i] = '_'; + } else if (encoded[i] == '=') { + out[i] = '-'; + } else { + out[i] = encoded[i]; + } + } while (encoded[i++]); + + g_free(encoded); } static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, |