diff options
author | Ben Gamari <ben@smart-cactus.org> | 2017-03-27 12:40:42 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-29 14:23:29 -0400 |
commit | b04ded8fca8ee8b0cd9c7c055bc5dc61ef2be1fe (patch) | |
tree | 09ba2d2507f258d27e63d529b21afcf402f5419a /libraries/base/System/IO.hs | |
parent | fb7e5bd350407888d6638e15d16aad311d7d9006 (diff) | |
download | haskell-b04ded8fca8ee8b0cd9c7c055bc5dc61ef2be1fe.tar.gz |
base: Check for path separators chars in openTempFile' template string
This fixes #13489.
Diffstat (limited to 'libraries/base/System/IO.hs')
-rw-r--r-- | libraries/base/System/IO.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libraries/base/System/IO.hs b/libraries/base/System/IO.hs index d1ed9e3992..1796200bc4 100644 --- a/libraries/base/System/IO.hs +++ b/libraries/base/System/IO.hs @@ -441,7 +441,8 @@ fixIO k = do openTempFile :: FilePath -- ^ Directory in which to create the file -> String -- ^ File name template. If the template is \"foo.ext\" then -- the created file will be \"fooXXX.ext\" where XXX is some - -- random number. + -- random number. Note that this should not contain any path + -- separator characters. -> IO (FilePath, Handle) openTempFile tmp_dir template = openTempFile' "openTempFile" tmp_dir template False 0o600 @@ -465,7 +466,10 @@ openBinaryTempFileWithDefaultPermissions tmp_dir template openTempFile' :: String -> FilePath -> String -> Bool -> CMode -> IO (FilePath, Handle) -openTempFile' loc tmp_dir template binary mode = findTempName +openTempFile' loc tmp_dir template binary mode + | pathSeparator `elem` template + = fail $ "openTempFile': Template string must not contain path separator characters: "++template + | otherwise = findTempName where -- We split off the last extension, so we can use .foo.ext files -- for temporary files (hidden on Unix OSes). Unfortunately we're |