diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2021-01-13 02:03:57 -0500 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2021-01-14 15:59:56 -0500 |
commit | 70c4fad73420d34e15234408ce26f59f04d99b3b (patch) | |
tree | 405f9486be3f7e546d55456f199a1f70f449d5a2 /.gitattributes | |
parent | 8f32ead8bf38ba7cb86c98f16db7c0e28a5c07c8 (diff) | |
download | curl-70c4fad73420d34e15234408ce26f59f04d99b3b.tar.gz |
gitattributes: Set batch files to CRLF line endings on checkout
If a batch file is run without CRLF line endings (ie LF-only) then
arbitrary behavior may occur. I consider that a bug in Windows, however
the effects can be serious enough (eg unintended code executed) that
we're fixing it in the repo by requiring CRLF line endings for batch
files on checkout.
Prior to this change the checked-out line endings of batch files were
dependent on a user's git preferences. On Windows it is common for git
users to have automatic CRLF conversion enabled (core.autocrlf true),
but those users that don't would run into this behavior.
For example a user has reported running the Visual Studio project
generator batch file (projects/generate.bat) and it looped forever.
Output showed that the Windows OS interpreter was occasionally jumping
to arbitrary points in the batch file and executing commands. This
resulted in unintended files being removed (a removal sequence called)
and looping forever.
Ref: https://serverfault.com/q/429594
Ref: https://stackoverflow.com/q/232651
Ref: https://www.dostips.com/forum/viewtopic.php?t=8988
Ref: https://git-scm.com/docs/gitattributes#_checking_out_and_checking_in
Ref: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf
Bug: https://github.com/curl/curl/discussions/6427
Reported-by: Ganesh Kamath
Closes https://github.com/curl/curl/pull/6442
Diffstat (limited to '.gitattributes')
-rw-r--r-- | .gitattributes | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes index cd3fde954..691da6228 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,3 +6,9 @@ configure.ac eol=lf *.am eol=lf *.sh eol=lf *.[ch] whitespace=tab-in-indent + +# Batch files (bat,btm,cmd) must be run with CRLF line endings. +# Refer to https://github.com/curl/curl/pull/6442 +*.bat text eol=crlf +*.btm text eol=crlf +*.cmd text eol=crlf |