فهرست منبع

* Fixed some uninitialised values, 500 more to go!
Valgrind was making a fuss about these ones though...


svn: 687

Bryan Drewery 22 سال پیش
والد
کامیت
06b9230178
5فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 2 2
      src/dcc.c
  2. 5 5
      src/dccutil.c
  3. 1 1
      src/mod/channels.mod/tclchan.c
  4. 1 1
      src/mod/server.mod/servmsg.c
  5. 2 1
      src/net.c

+ 2 - 2
src/dcc.c

@@ -344,7 +344,7 @@ static void cont_link(int idx, char *buf, int ii)
 {
   /* Now set the initial link key (incoming only, we're not sending more until we get an OK)... */
   struct sockaddr_in sa;
-  char tmp[256], bufout[SHA_HASH_LENGTH + 1];
+  char tmp[256] = "", bufout[SHA_HASH_LENGTH + 1] = "";
   SHA_CTX ctx;
   int i;
   int snum = -1;
@@ -377,7 +377,7 @@ static void cont_link(int idx, char *buf, int ii)
     /* initkey-gen leaf */
     /* bdhash myport hubnick mynick */
     getsockname(socklist[snum].sock, (struct sockaddr *) &sa, &i);
-    sprintf(tmp,"%s@%4x@%s@%s", bdhash, sa.sin_port, dcc[idx].nick, conf.bot->nick);
+    egg_snprintf(tmp, sizeof tmp, "%s@%4x@%s@%s", bdhash, sa.sin_port, dcc[idx].nick, conf.bot->nick);
     SHA1_Init(&ctx);
     SHA1_Update(&ctx, tmp, strlen(tmp));
     SHA1_Final(bufout, &ctx);

+ 5 - 5
src/dccutil.c

@@ -81,8 +81,8 @@ extern void (*qserver) (int, char *, int);
 
 void dprintf (int idx, ...)
 {
-  static char buf[1024];
-  char *format; 
+  static char buf[1024] = "";
+  char *format = NULL;
   int len;
   va_list va;
 
@@ -147,7 +147,7 @@ void dprintf (int idx, ...)
   } else { /* normal chat text */
     if ((dcc[idx].status & STAT_COLOR) && (dcc[idx].type == &DCC_CHAT)) {
       int i;
-      char buf3[1024], buf2[1024], c;
+      char buf3[1024] = "", buf2[1024] = "", c;
 
       buf3[0] = buf2[0] = 0;
       for (i = 0 ; i < len ; i++) {
@@ -206,7 +206,7 @@ void dprintf (int idx, ...)
 void chatout (char *format, ...)
 {
   int i, len;
-  char s[601];
+  char s[601] = "";
   va_list va;
 
   va_start(va, format);
@@ -230,7 +230,7 @@ void chanout_but (int x, ...)
 {
   int i, chan, len;
   char *format;
-  char s[601];
+  char s[601] = "";
   va_list va;
 
   va_start(va, x);

+ 1 - 1
src/mod/channels.mod/tclchan.c

@@ -461,7 +461,7 @@ static int tcl_channel_add(Tcl_Interp *irp, char *newname, char *options)
   int items;
   int ret = TCL_OK;
   int join = 0;
-  char buf[2048], buf2[256];
+  char buf[2048] = "", buf2[256] = "";
 #if (((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)) || (TCL_MAJOR_VERSION > 8))
   CONST char **item;
 #else

+ 1 - 1
src/mod/server.mod/servmsg.c

@@ -1140,7 +1140,7 @@ static void server_resolve_failure(int);
  */
 static void connect_server(void)
 {
-  char pass[121], botserver[UHOSTLEN];
+  char pass[121] = "", botserver[UHOSTLEN] = "";
   static int oldserv = -1;
   unsigned int botserverport = 0;
 

+ 2 - 1
src/net.c

@@ -99,7 +99,8 @@ int hostprotocol(char *host)
 #  ifndef HAVE_GETHOSTBYNAME2
   int error_num;
 #  endif /* !HAVE_GETHOSTBYNAME2 */
-
+  if (!host || (host && !host[0]))
+    return 0;
   if (!setjmp(alarmret)) {
     alarm(resolve_timeout);