Changeset b38d399 for protocols


Ignore:
Timestamp:
2014-11-24T05:16:09Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
9f8bb17
Parents:
e2472dd
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/libyahoo2.c

    re2472dd rb38d399  
    681681}
    682682
    683 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
     683/* yahoo's variant of base64 */
    684684static void to_y64(unsigned char *out, const unsigned char *in, int inlen)
    685685{
    686         base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
     686        char *encoded = base64_encode(in, inlen);
     687        int i = 0;
     688
     689        do {
     690                if (encoded[i] == '+') {
     691                        out[i] = '.';
     692                } else if (encoded[i] == '/') {
     693                        out[i] = '_';
     694                } else if (encoded[i] == '=') {
     695                        out[i] = '-';
     696                } else {
     697                        out[i] = encoded[i];
     698                }
     699        } while (encoded[i++]);
     700
     701        g_free(encoded);
    687702}
    688703
Note: See TracChangeset for help on using the changeset viewer.