openbsd-ports/net/bitlbee/patches/patch-set_c
simon 53e6084bfe update to version 1.0.3
from Martynas Venckus <martynas at altroot dot org>
2007-01-14 21:53:01 +00:00

63 lines
1.7 KiB
Plaintext

$OpenBSD: patch-set_c,v 1.2 2007/01/14 21:53:01 simon Exp $
--- set.c.orig Sat Jun 24 17:00:43 2006
+++ set.c Fri Dec 15 21:20:08 2006
@@ -35,14 +35,20 @@ set_t *set_add( irc_t *irc, char *key, c
{
while( s->next ) s = s->next;
s->next = g_new ( set_t, 1 );
+ if (!s->next)
+ return NULL;
s = s->next;
}
else
{
s = irc->set = g_new( set_t, 1 );
+ if (!s)
+ return NULL;
}
memset( s, 0, sizeof( set_t ) );
s->key = g_strdup( key );
+ if (!s->key)
+ return NULL;
}
if( s->def )
@@ -133,7 +139,7 @@ int set_setint( irc_t *irc, char *key, i
{
char s[24]; /* Not quite 128-bit clean eh? ;-) */
- sprintf( s, "%d", value );
+ snprintf( s, sizeof(s), "%d", value );
return( set_setstr( irc, key, s ) );
}
@@ -183,12 +189,16 @@ char *set_eval_bool( irc_t *irc, set_t *
char *set_eval_to_char( irc_t *irc, set_t *set, char *value )
{
- char *s = g_new( char, 3 );
+ size_t s_len = 3;
+ char *s = g_new( char, s_len );
+
+ if (!s)
+ return NULL;
if( *value == ' ' )
- strcpy( s, " " );
+ strlcpy( s, " ", s_len );
else
- sprintf( s, "%c ", *value );
+ g_snprintf( s, s_len, "%c ", *value );
return( s );
}
@@ -201,7 +211,7 @@ char *set_eval_ops( irc_t *irc, set_t *s
irc->channel, "+o-o", irc->nick, irc->mynick );
return( value );
}
- else if( g_strcasecmp( value, "root" ) == 0 )
+ else if( g_strcasecmp( value, ROOT_NICK ) == 0 || g_strcasecmp( value, "root" ) == 0 )
{
irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost,
irc->channel, "-o+o", irc->nick, irc->mynick );