Sfoglia il codice sorgente

* Fix more warnings about unused results (warn_unused_result)

Bryan Drewery 17 anni fa
parent
commit
2ffd51b3fb
4 ha cambiato i file con 15 aggiunte e 6 eliminazioni
  1. 3 1
      src/conf.c
  2. 3 2
      src/main.c
  3. 3 1
      src/misc_file.c
  4. 6 2
      src/shell.c

+ 3 - 1
src/conf.c

@@ -1130,7 +1130,9 @@ bin_to_conf(bool error)
   }
 
   char datadir[PATH_MAX] = "";
-  realpath(conf.datadir, datadir);
+  if (!realpath(conf.datadir, datadir))
+    werr(ERR_DATADIR);
+
   str_redup(&conf.datadir, datadir);
   if (!mkdir_p(conf.datadir) && error)
     werr(ERR_DATADIR);

+ 3 - 2
src/main.c

@@ -106,7 +106,7 @@ uid_t   myuid;
 pid_t   mypid;
 bool	term_z = 0;		/* Foreground: use the terminal as a party line? */
 int 	updating = 0; 		/* this is set when the binary is called from itself. */
-char 	tempdir[DIRMAX] = "";
+char 	tempdir[PATH_MAX] = "";
 char 	*binname = NULL;
 time_t	online_since;		/* Unix-time that the bot loaded up */
 time_t  restart_time;
@@ -171,7 +171,8 @@ static char *getfullbinname(const char *argv_zero)
   bin[strlen(bin)] = 0;
 #endif /* CYGWIN_HACKS */
   /* Fix for symlinked binaries */
-  realpath(bin, buf);
+  if (!realpath(bin, buf))
+    fatal(STR("realpath() failed"), 0);
   size_t len = strlen(buf);
   bin = (char *) my_realloc(bin, len + 1);
   strlcpy(bin, buf, len + 1);

+ 3 - 1
src/misc_file.c

@@ -322,7 +322,9 @@ bool Tempfile::FindDir()
   };
 
   for (int i = 0; dirs[i]; i++) {
-    realpath(dirs[i], tempdir);
+    if (!realpath(dirs[i], tempdir))
+      continue;
+    tempdir[DIRMAX] = 0;
     size_t len = strlen(tempdir);
     tempdir[len] = '/';
     tempdir[len + 1] = '\0';

+ 6 - 2
src/shell.c

@@ -748,7 +748,10 @@ char *homedir(bool useconf)
     }
     ContextNote(STR("realpath()"));
     if (tmp[0]) {
-      realpath(tmp, homedir_buf); /* this will convert lame home dirs of /home/blah->/usr/home/blah */
+      if (!realpath(tmp, homedir_buf)) { /* this will convert lame home dirs of /home/blah->/usr/home/blah */
+        homedir_buf[0] = 0;
+        return NULL;
+      }
       homedir_buf[DIRMAX] = 0;
     }
     ContextNote(STR("realpath(): Success"));
@@ -865,7 +868,8 @@ char *move_bin(const char *ipath, const char *file, bool run)
   simple_snprintf(newbin, sizeof newbin, "%s%s%s", path, path[strlen(path) - 1] == '/' ? "" : "/", file);
 
   ContextNote(STR("realpath()"));
-  realpath(binname, real);            /* get the realpath of binname */
+  if (!realpath(binname, real))            /* get the realpath of binname */
+    fatal(STR("Unable to determine binary path."), 0);
   real[DIRMAX] = 0;
   ContextNote(STR("realpath(): Success"));
   /* running from wrong dir, or wrong bin name.. lets try to fix that :) */