Przeglądaj źródła

Only disallow directories as input files

June 5 lat temu
rodzic
commit
2b7b7f7f72
1 zmienionych plików z 2 dodań i 6 usunięć
  1. 2 6
      src/google/protobuf/compiler/importer.cc

+ 2 - 6
src/google/protobuf/compiler/importer.cc

@@ -495,12 +495,8 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(
   do {
     ret = stat(filename.c_str(), &sb);
   } while (ret != 0 && errno == EINTR);
-#ifdef _WIN32
-  if ((sb.st_mode & _S_IFMT) == _S_IFREG) {
-#else
-  if (!S_ISREG(sb.st_mode)) {
-#endif
-    last_error_message_ = "Input file is not a regular file.";
+  if (sb.st_mode & S_IFDIR) {
+    last_error_message_ = "Input file is a directory.";
     return NULL;
   }
   int file_descriptor;