Fixing core dump bug with unix password sync, caused by a NULL
authorMatthew Chapman <matty@samba.org>
Wed, 2 Jun 1999 04:11:50 +0000 (04:11 +0000)
committerMatthew Chapman <matty@samba.org>
Wed, 2 Jun 1999 04:11:50 +0000 (04:11 +0000)
connection_struct in a call to OpenDir.
JF, you fixed a similar bug in printing/nt_printing.c, I think your fix
is incorrect as global configuration files should not go through a VFS.

source/smbd/chgpasswd.c

index c22f26868486a9129c000761fb30ddb9ec18b8e7..734f72c08daf2f87e296f41a4bf24b93a616b067 100644 (file)
@@ -60,7 +60,8 @@ static int findpty(char **slave)
   int master;
 #ifndef HAVE_GRANTPT
   static fstring line;
   int master;
 #ifndef HAVE_GRANTPT
   static fstring line;
-  void *dirp;
+  DIR *dirp;
+  struct dirent *dentry;
   char *dpname;
 #endif /* !HAVE_GRANTPT */
   
   char *dpname;
 #endif /* !HAVE_GRANTPT */
   
@@ -82,10 +83,11 @@ static int findpty(char **slave)
 #else /* HAVE_GRANTPT */
   fstrcpy( line, "/dev/ptyXX" );
 
 #else /* HAVE_GRANTPT */
   fstrcpy( line, "/dev/ptyXX" );
 
-  dirp = OpenDir(NULL, "/dev", False);
+  dirp = opendir("/dev");
   if (!dirp)
     return(-1);
   if (!dirp)
     return(-1);
-  while ((dpname = ReadDirName(dirp)) != NULL) {
+  while ((dentry = readdir(dirp)) != NULL) {
+    dpname = dentry->d_name;
     if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
       DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) );
       line[8] = dpname[3];
     if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
       DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) );
       line[8] = dpname[3];
@@ -94,12 +96,12 @@ static int findpty(char **slave)
         DEBUG(3,("pty: opened %s\n", line ) );
         line[5] = 't';
         *slave = line;
         DEBUG(3,("pty: opened %s\n", line ) );
         line[5] = 't';
         *slave = line;
-        CloseDir(dirp);
+        closedir(dirp);
         return (master);
       }
     }
   }
         return (master);
       }
     }
   }
-  CloseDir(dirp);
+  closedir(dirp);
 #endif /* HAVE_GRANTPT */
   return (-1);
 }
 #endif /* HAVE_GRANTPT */
   return (-1);
 }