Imported Upstream version 1.8.7
[debian/sudo] / plugins / sudoers / find_path.c
index 208b88e40e090bb31731307c33ca2a3acaca90b6..2d5261372975649325fa0e7f61cc6840996a970d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 1998-2005, 2010-2011
+ * Copyright (c) 1996, 1998-2005, 2010-2013
  *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -22,7 +22,6 @@
 #include <config.h>
 
 #include <sys/types.h>
-#include <sys/param.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #ifdef STDC_HEADERS
@@ -65,8 +64,10 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
     int len;                   /* length parameter */
     debug_decl(find_path, SUDO_DEBUG_UTIL)
 
-    if (strlen(infile) >= PATH_MAX)
-       errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+    if (strlen(infile) >= PATH_MAX) {
+       errno = ENAMETOOLONG;
+       fatal("%s", infile);
+    }
 
     /*
      * If we were given a fully qualified or relative path
@@ -104,8 +105,10 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
         * Resolve the path and exit the loop if found.
         */
        len = snprintf(command, sizeof(command), "%s/%s", path, infile);
-       if (len <= 0 || len >= sizeof(command))
-           errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+       if (len <= 0 || len >= sizeof(command)) {
+           errno = ENAMETOOLONG;
+           fatal("%s", infile);
+       }
        if ((found = sudo_goodpath(command, sbp)))
            break;
 
@@ -119,8 +122,10 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
      */
     if (!found && checkdot) {
        len = snprintf(command, sizeof(command), "./%s", infile);
-       if (len <= 0 || len >= sizeof(command))
-           errorx(1, _("%s: %s"), infile, strerror(ENAMETOOLONG));
+       if (len <= 0 || len >= sizeof(command)) {
+           errno = ENAMETOOLONG;
+           fatal("%s", infile);
+       }
        found = sudo_goodpath(command, sbp);
        if (found && ignore_dot)
            debug_return_int(NOT_FOUND_DOT);