incorrect handling of batch files by cmd.exe, if Unix (LF) line ending is used

New Contributor

hello,

 

while running batch file with Unix (LF) line ending got error:

 

The system cannot find the batch label specified - Test

 

, see testcase in attachment.

 

reproduced, if:
- Unix (LF) line ending is used in batch file
not reproduced, if:
- Unix (LF) line ending is used in batch file, but at least one word was added or removed in comments of ':Main' subroutine (line:6-10)
- Windows (CR LF) is used in batch file

 

presumably, because of Unix (LF) line ending use, 'cmd.exe' memory allocation algorithm fails to guess size of the array, sufficient to place ':Main' subroutine for parsing. so it is placed out of bonds and damages ':Test' subroutine. which resulted, that ':Test' label became unavailable and calling it finishes with error.

 

even though Windows Command Prompt expected to work with Windows (CR LF) line ending, not Unix (LF), this tescase may reproduce Undefined Behavior, which is unlikely a feature. can it be fixed?

 

 

best,
Alex Shevchenko

 

 

 

0 Replies