diff options
author | Brad King <brad.king@kitware.com> | 2017-02-28 14:39:21 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-02-28 14:39:21 (GMT) |
commit | 30243e7fafee60a8ef6ffc6fb8eed09548a86aa9 (patch) | |
tree | f8ed56019a67ea698e8960857816bf51e4563b8e /Source | |
parent | dda1805f27c40028924cf367492d6990dcf31e96 (diff) | |
parent | ded616bdad46a445ea7ae05d47ae8f32026b13b5 (diff) | |
download | CMake-30243e7fafee60a8ef6ffc6fb8eed09548a86aa9.zip CMake-30243e7fafee60a8ef6ffc6fb8eed09548a86aa9.tar.gz CMake-30243e7fafee60a8ef6ffc6fb8eed09548a86aa9.tar.bz2 |
Merge topic '16607-error-out-on-non-seekable-input-files'
ded616bd cmListFileLexer: bail out on seek-errors
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmListFileCache.cxx | 7 | ||||
-rw-r--r-- | Source/cmListFileLexer.c | 8 | ||||
-rw-r--r-- | Source/cmListFileLexer.h | 1 |
3 files changed, 14 insertions, 2 deletions
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, |