Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _chsize_s on Windows for truncate #24616

Merged
merged 2 commits into from
Dec 9, 2017
Merged

Use _chsize_s on Windows for truncate #24616

merged 2 commits into from
Dec 9, 2017

Conversation

jaakkor2
Copy link
Contributor

Proposal to fix #24466 . Should allow files >2 GB to be truncated on Windows.

Proposal to fix #24466 .  Should allow files >2 GB to be truncated on Windows.
@@ -566,7 +566,11 @@ int ios_trunc(ios_t *s, size_t size)
#if !defined(_OS_WINDOWS_)
if (ftruncate(s->fd, size) == 0)
#else
if (_chsize(s->fd, size) == 0)
#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API)
if (_chsize_s(s->fd, size) == 0)
Copy link
Member

@vtjnash vtjnash Nov 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just use this function everywhere. I don't see any reason we should need the alternate code path.

Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe  , libgit2.dll does use `_chsize_c`, so both 32bit and 64bit should be able to use `_chsize_c`.
@jaakkor2
Copy link
Contributor Author

Alternate code path removed.

@ararslan ararslan added filesystem Underlying file system and functions that use it system:windows Affects only Windows labels Nov 15, 2017
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

(Although we might want to wait to merge until the windows buildbot is actually running, so please don't take a delay here the wrong way.)

@vtjnash vtjnash merged commit ff045af into JuliaLang:master Dec 9, 2017
evetion pushed a commit to evetion/julia that referenced this pull request Dec 12, 2017
Should allow files >2 GB to be truncated on Windows.

Fix JuliaLang#24466

Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe, libgit2.dll already uses `_chsize_s`, so both 32bit and 64bit should be able to use `_chsize_s`.
@jaakkor2 jaakkor2 deleted the patch-1 branch January 8, 2018 14:13
ararslan pushed a commit that referenced this pull request Apr 26, 2018
Should allow files >2 GB to be truncated on Windows.

Fix #24466

Checking Windows 32bit build https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6.1-win32.exe, libgit2.dll already uses `_chsize_s`, so both 32bit and 64bit should be able to use `_chsize_s`.

Ref #24616
(cherry picked from commit ff045af)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filesystem Underlying file system and functions that use it system:windows Affects only Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integer truncation in truncate on Windows
4 participants