openbsd-ports/net/bitlbee/patches/patch-crypting_c

39 lines
1.0 KiB
Plaintext

$OpenBSD: patch-crypting_c,v 1.2 2006/04/11 15:11:33 naddy Exp $
--- crypting.c.orig Sun Jan 15 02:04:28 2006
+++ crypting.c Sun Jan 29 03:27:22 2006
@@ -117,11 +117,15 @@ char *hashpass (irc_t *irc) {
int i;
char digits[3];
char *rv;
+ size_t rv_len;
if (irc->password == NULL) return (NULL);
- rv = (char *)g_malloc (33);
- memset (rv, 0, 33);
+ rv_len = 33;
+ rv = (char *)g_malloc (rv_len);
+ if (!rv) return NULL;
+
+ memset (rv, 0, rv_len);
md5_init (&md5state);
md5_append (&md5state, (unsigned char *)irc->password, strlen (irc->password));
@@ -130,7 +134,7 @@ char *hashpass (irc_t *irc) {
for (i = 0; i < 16; i++) {
/* Build a hash of the pass */
g_snprintf (digits, sizeof (digits), "%02x", digest[i]);
- strcat (rv, digits);
+ strlcat (rv, digits, rv_len);
}
return (rv);
@@ -229,6 +233,7 @@ int main( int argc, char *argv[] )
return( main( 0, NULL ) );
}
+ COMPILE_TIME_ASSERTION(255 < sizeof(s));
while( fscanf( stdin, "%[^\n]255s", line ) > 0 )
{
char *out;