]> granicus.if.org Git - sudo/commitdiff
now check to see that st_dev is non-zero before assuming that we
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 23 Jun 1995 00:25:06 +0000 (00:25 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 23 Jun 1995 00:25:06 +0000 (00:25 +0000)
are being spoofed

sudo.c

diff --git a/sudo.c b/sudo.c
index be4400a94bd38b76764e6eb47ff0ad96c770a676..88970af3ae835ff2b0b0a39261824c68abf38a76 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -238,23 +238,27 @@ main(argc, argv)
            if (sudo_mode == MODE_BACKGROUND && fork() > 0) {
                exit(0);
            } else {
-               struct stat st;
-
                /*
                 * Make sure we are not being spoofed.  The stat should
                 * be cheap enough to make this almost bulletproof.
                 */
-               if (stat(cmnd, &st) < 0) {
-                   fprintf(stderr, "%s: unable to stat %s:", Argv[0], cmnd);
-                   perror("");
-                   exit(1);
-               }
-
-               if (st.st_dev != cmnd_st.st_dev || st.st_ino != cmnd_st.st_ino) {
-                   /* log and send mail, then bitch */
-                   log_error(SPOOF_ATTEMPT);
-                   inform_user(SPOOF_ATTEMPT);
-                   exit(1);
+               if (cmnd_st.st_dev) {
+                   struct stat st;
+
+                   if (stat(cmnd, &st) < 0) {
+                       fprintf(stderr, "%s: unable to stat %s:", Argv[0],
+                                       cmnd);
+                       perror("");
+                       exit(1);
+                   }
+
+                   if (st.st_dev != cmnd_st.st_dev ||
+                       st.st_ino != cmnd_st.st_ino) {
+                       /* log and send mail, then bitch */
+                       log_error(SPOOF_ATTEMPT);
+                       inform_user(SPOOF_ATTEMPT);
+                       exit(1);
+                   }
                }
 
                EXEC(cmnd, &Argv[1]);