[Cmake-commits] CMake branch, next, updated. v3.8.0-rc1-552-g0da16ec

Brad King brad.king at kitware.com
Fri Feb 24 11:13:46 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  0da16ecd007f3a444aefa6f70fe075ed09dbb795 (commit)
       via  988b1e9b3b974c3eddea1c4171989353a8c2f3ff (commit)
      from  3cc17beb1eb141920e16afe1a0739765db33ec88 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0da16ecd007f3a444aefa6f70fe075ed09dbb795
commit 0da16ecd007f3a444aefa6f70fe075ed09dbb795
Merge: 3cc17be 988b1e9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Feb 24 11:13:45 2017 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Feb 24 11:13:45 2017 -0500

    Merge topic '16607-error-out-on-non-seekable-input-files' into next
    
    988b1e9b cmListFileLexer: bail out on seek-errors


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=988b1e9b3b974c3eddea1c4171989353a8c2f3ff
commit 988b1e9b3b974c3eddea1c4171989353a8c2f3ff
Author:     Gregor Jasny <gjasny at googlemail.com>
AuthorDate: Sun Feb 19 18:26:44 2017 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Feb 24 11:13:37 2017 -0500

    cmListFileLexer: bail out on seek-errors
    
    If we are given a FIFO, for example, we cannot seek back after trying to
    read a Byte-Order-Mark.
    
    Closes: #16607

diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index b1cd889..23b666e 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -80,6 +80,13 @@ bool cmListFileParser::ParseFile()
     return false;
   }
 
+  if (bom == cmListFileLexer_BOM_Broken) {
+    cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
+    this->IssueFileOpenError("Error while reading Byte-Order-Mark. "
+                             "File not seekable?");
+    return false;
+  }
+
   // Verify the Byte-Order-Mark, if any.
   if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
     cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c
index 56559f6..44d0894 100644
--- a/Source/cmListFileLexer.c
+++ b/Source/cmListFileLexer.c
@@ -2559,11 +2559,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
       if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
         return cmListFileLexer_BOM_UTF32LE;
       }
-      fsetpos(f, &p);
+      if (fsetpos(f, &p) != 0) {
+        return cmListFileLexer_BOM_Broken;
+      }
       return cmListFileLexer_BOM_UTF16LE;
     }
   }
-  rewind(f);
+  if (fseek(f, 0, SEEK_SET) != 0) {
+    return cmListFileLexer_BOM_Broken;
+  }
   return cmListFileLexer_BOM_None;
 }
 
diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h
index c9fb6da..f243010a 100644
--- a/Source/cmListFileLexer.h
+++ b/Source/cmListFileLexer.h
@@ -32,6 +32,7 @@ struct cmListFileLexer_Token_s
 enum cmListFileLexer_BOM_e
 {
   cmListFileLexer_BOM_None,
+  cmListFileLexer_BOM_Broken,
   cmListFileLexer_BOM_UTF8,
   cmListFileLexer_BOM_UTF16BE,
   cmListFileLexer_BOM_UTF16LE,
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 0c4f71c..0c79856 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -301,3 +301,12 @@ set(CMAKE_RELATIVE_PATH_TOP_BINARY \"${RunCMake_TEST_BINARY_DIR}\")
     )
 endfunction()
 run_cmake_depends()
+
+function(reject_fifo)
+  find_program(BASH_EXECUTABLE bash)
+  if(CMAKE_HOST_UNIX AND BASH_EXECUTABLE)
+    set(BASH_COMMAND_ARGUMENT "'${CMAKE_COMMAND}' -P <(echo 'return()')")
+    run_cmake_command(reject_fifo ${BASH_EXECUTABLE} -c ${BASH_COMMAND_ARGUMENT})
+  endif()
+endfunction()
+reject_fifo()
diff --git a/Tests/RunCMake/CommandLine/reject_fifo-result.txt b/Tests/RunCMake/CommandLine/reject_fifo-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/reject_fifo-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/reject_fifo-stderr.txt b/Tests/RunCMake/CommandLine/reject_fifo-stderr.txt
new file mode 100644
index 0000000..7a335c3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/reject_fifo-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in .*
+  Error while reading Byte-Order-Mark\.  File not seekable\?

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list