]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/conf.c
s/sprintf/snprintf
[ngircd.git] / src / ngircd / conf.c
index 412402fc727bebeb2102113119c8db284aabbee4..77e52cb69b571d2863d54243276130fd4956a900 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.73 2005/03/20 13:54:06 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.77 2005/06/17 19:16:53 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -105,8 +105,9 @@ Conf_Test( void )
        Read_Config( );
        Validate_Config( true );
 
-       /* If stdin is a valid tty wait for a key: */
-       if( isatty( fileno( stdout )))
+       /* If stdin and stdout ("you can read our nice message and we can
+        * read in your keypress") are valid tty's, wait for a key: */
+       if( isatty( fileno( stdin )) && isatty( fileno( stdout )))
        {
                puts( "OK, press enter to see a dump of your service configuration ..." );
                getchar( );
@@ -345,7 +346,7 @@ Set_Defaults( bool InitServers )
        int i;
 
        strcpy( Conf_ServerName, "" );
-       sprintf( Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
+       snprintf( Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
        strcpy( Conf_ServerPwd, "" );
 
        strcpy( Conf_ServerAdmin1, "" );
@@ -803,7 +804,6 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
 LOCAL void
 Handle_OPERATOR( int Line, char *Var, char *Arg )
 {
-       unsigned int len;
        assert( Line > 0 );
        assert( Var != NULL );
        assert( Arg != NULL );
@@ -824,14 +824,12 @@ Handle_OPERATOR( int Line, char *Var, char *Arg )
        if( strcasecmp( Var, "Mask" ) == 0 )
        {
                if (Conf_Oper[Conf_Oper_Count - 1].mask) return; /* Hostname already configured */
-               len = strlen( Arg ) + 1;
-               Conf_Oper[Conf_Oper_Count - 1].mask = malloc( len );
+               Conf_Oper[Conf_Oper_Count - 1].mask = strdup( Arg );
                if (! Conf_Oper[Conf_Oper_Count - 1].mask) {
                        Config_Error( LOG_ERR, "%s, line %d: Cannot allocate memory for operator mask: %s", NGIRCd_ConfFile, Line, strerror(errno) );
                        return;
                }
 
-               strlcpy( Conf_Oper[Conf_Oper_Count - 1].mask, Arg, len);
                return;
        }
        Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );