aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/base64.c4
-rw-r--r--lib/base64.h2
-rw-r--r--lib/rc4.c8
-rw-r--r--lib/rc4.h4
-rw-r--r--protocols/jabber/sasl.c7
-rw-r--r--storage_xml.c15
6 files changed, 22 insertions, 18 deletions
diff --git a/lib/base64.c b/lib/base64.c
index 69069dae..64e9692a 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -30,10 +30,10 @@ static const char real_b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv
char *tobase64(const char *text)
{
- return base64_encode(text, strlen(text));
+ return base64_encode((const unsigned char *)text, strlen(text));
}
-char *base64_encode(const char *in, int len)
+char *base64_encode(const unsigned char *in, int len)
{
char *out;
diff --git a/lib/base64.h b/lib/base64.h
index 570f2b14..ebd74bf1 100644
--- a/lib/base64.h
+++ b/lib/base64.h
@@ -26,7 +26,7 @@
#include <gmodule.h>
G_MODULE_EXPORT char *tobase64( const char *text );
-G_MODULE_EXPORT char *base64_encode( const char *in, int len );
+G_MODULE_EXPORT char *base64_encode( const unsigned char *in, int len );
G_MODULE_EXPORT int base64_encode_real( const unsigned char *in, int inlen, unsigned char *out, const char *b64digits );
G_MODULE_EXPORT char *frombase64( const char *in );
G_MODULE_EXPORT int base64_decode( const char *in, unsigned char **out );
diff --git a/lib/rc4.c b/lib/rc4.c
index f2c76f54..635b802a 100644
--- a/lib/rc4.c
+++ b/lib/rc4.c
@@ -121,7 +121,7 @@ unsigned char rc4_getbyte( struct rc4_state *st )
Both functions return the number of bytes in the result string.
*/
-int rc4_encode( unsigned char *clear, int clear_len, unsigned char **crypt, char *password )
+int rc4_encode( char *clear, int clear_len, unsigned char **crypt, char *password )
{
struct rc4_state *st;
unsigned char *key;
@@ -129,7 +129,7 @@ int rc4_encode( unsigned char *clear, int clear_len, unsigned char **crypt, char
key_len = strlen( password ) + RC4_IV_LEN;
if( clear_len <= 0 )
- clear_len = strlen( (char*) clear );
+ clear_len = strlen( clear );
/* Prepare buffers and the key + IV */
*crypt = g_malloc( clear_len + RC4_IV_LEN );
@@ -153,7 +153,7 @@ int rc4_encode( unsigned char *clear, int clear_len, unsigned char **crypt, char
return clear_len + RC4_IV_LEN;
}
-int rc4_decode( unsigned char *crypt, int crypt_len, unsigned char **clear, char *password )
+int rc4_decode( unsigned char *crypt, int crypt_len, char **clear, char *password )
{
struct rc4_state *st;
unsigned char *key;
@@ -164,7 +164,7 @@ int rc4_decode( unsigned char *crypt, int crypt_len, unsigned char **clear, char
if( clear_len < 0 )
{
- *clear = (unsigned char*) g_strdup( "" );
+ *clear = g_strdup( "" );
return 0;
}
diff --git a/lib/rc4.h b/lib/rc4.h
index 2d4d3cc8..52de06b1 100644
--- a/lib/rc4.h
+++ b/lib/rc4.h
@@ -32,5 +32,5 @@ struct rc4_state
struct rc4_state *rc4_keymaker( unsigned char *key, int kl, int cycles );
unsigned char rc4_getbyte( struct rc4_state *st );
-int rc4_encode( unsigned char *clear, int clear_len, unsigned char **crypt, char *password );
-int rc4_decode( unsigned char *crypt, int crypt_len, unsigned char **clear, char *password );
+int rc4_encode( char *clear, int clear_len, unsigned char **crypt, char *password );
+int rc4_decode( unsigned char *crypt, int crypt_len, char **clear, char *password );
diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c
index 69199a8b..6eee37b3 100644
--- a/protocols/jabber/sasl.c
+++ b/protocols/jabber/sasl.c
@@ -88,7 +88,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
s[0] = 0;
strcpy( s + 1, jd->username );
strcpy( s + 2 + strlen( jd->username ), ic->acc->pass );
- reply->text = base64_encode( s, len );
+ reply->text = base64_encode( (unsigned char *)s, len );
reply->text_len = strlen( reply->text );
g_free( s );
}
@@ -184,7 +184,8 @@ xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
struct im_connection *ic = data;
struct jabber_data *jd = ic->proto_data;
struct xt_node *reply = NULL;
- char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30];
+ char *nonce = NULL, *realm = NULL, *cnonce = NULL;
+ unsigned char cnonce_bin[30];
char *digest_uri = NULL;
char *dec = NULL;
char *s = NULL;
@@ -215,7 +216,7 @@ xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
if( !realm )
realm = g_strdup( jd->server );
- random_bytes( (unsigned char *) cnonce_bin, sizeof( cnonce_bin ) );
+ random_bytes( cnonce_bin, sizeof( cnonce_bin ) );
cnonce = base64_encode( cnonce_bin, sizeof( cnonce_bin ) );
digest_uri = g_strdup_printf( "%s/%s", "xmpp", jd->server );
diff --git a/storage_xml.c b/storage_xml.c
index 00fca425..97379b29 100644
--- a/storage_xml.c
+++ b/storage_xml.c
@@ -131,7 +131,8 @@ static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_na
else if( g_strcasecmp( element_name, "account" ) == 0 )
{
char *protocol, *handle, *server, *password = NULL, *autoconnect;
- char *pass_b64 = NULL, *pass_rc4 = NULL;
+ char *pass_b64 = NULL;
+ unsigned char *pass_rc4 = NULL;
int pass_len;
struct prpl *prpl = NULL;
@@ -151,8 +152,9 @@ static void xml_start_element( GMarkupParseContext *ctx, const gchar *element_na
g_set_error( error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
"Unknown protocol: %s", protocol );
else if( ( pass_len = base64_decode( pass_b64, (unsigned char**) &pass_rc4 ) ) &&
- rc4_decode( (unsigned char*) pass_rc4, pass_len,
- (unsigned char**) &password, xd->given_pass ) )
+ rc4_decode( pass_rc4, pass_len,
+ &password,
+ xd->given_pass ) )
{
xd->current_account = account_add( irc, prpl, handle, password );
if( server )
@@ -409,7 +411,7 @@ static storage_status_t xml_save( irc_t *irc, int overwrite )
md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */
md5_finish( &md5_state, pass_md5 );
/* Save the hash in base64-encoded form. */
- pass_buf = base64_encode( (char*) pass_md5, 21 );
+ pass_buf = base64_encode( pass_md5, 21 );
if( !xml_printf( fd, 0, "<user nick=\"%s\" password=\"%s\" version=\"%d\">\n", irc->nick, pass_buf, XML_FORMAT_VERSION ) )
goto write_error;
@@ -423,10 +425,11 @@ static storage_status_t xml_save( irc_t *irc, int overwrite )
for( acc = irc->accounts; acc; acc = acc->next )
{
- char *pass_rc4, *pass_b64;
+ unsigned char *pass_rc4;
+ char *pass_b64;
int pass_len;
- pass_len = rc4_encode( (unsigned char*) acc->pass, strlen( acc->pass ), (unsigned char**) &pass_rc4, irc->password );
+ pass_len = rc4_encode( acc->pass, strlen( acc->pass ), (unsigned char**) &pass_rc4, irc->password );
pass_b64 = base64_encode( pass_rc4, pass_len );
g_free( pass_rc4 );