Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
92e4cad8
Commit
92e4cad8
authored
Aug 01, 2022
by
Arkadiusz Hiler
Committed by
Alexandre Julliard
Nov 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/tests: Make sure for /f doesn't loop infinitely on NULs.
parent
e1c37c21
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
batch.c
programs/cmd/tests/batch.c
+22
-0
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+3
-0
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+2
-0
No files found.
programs/cmd/tests/batch.c
View file @
92e4cad8
...
@@ -455,6 +455,24 @@ static int cmd_available(void)
...
@@ -455,6 +455,24 @@ static int cmd_available(void)
return
FALSE
;
return
FALSE
;
}
}
void
create_nul_test_file
(
void
)
{
HANDLE
file
;
DWORD
size
;
BOOL
bres
;
char
contents
[]
=
"a b c
\n
d e
\0
f
\n
g h i"
;
file
=
CreateFileA
(
"nul_test_file"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"CreateFile failed
\n
"
);
if
(
file
==
INVALID_HANDLE_VALUE
)
return
;
bres
=
WriteFile
(
file
,
contents
,
ARRAYSIZE
(
contents
),
&
size
,
NULL
);
ok
(
bres
,
"Could not write to file: %lu
\n
"
,
GetLastError
());
CloseHandle
(
file
);
}
START_TEST
(
batch
)
START_TEST
(
batch
)
{
{
int
argc
;
int
argc
;
...
@@ -479,9 +497,13 @@ START_TEST(batch)
...
@@ -479,9 +497,13 @@ START_TEST(batch)
}
}
shortpath_len
=
GetShortPathNameA
(
path
,
shortpath
,
ARRAY_SIZE
(
shortpath
));
shortpath_len
=
GetShortPathNameA
(
path
,
shortpath
,
ARRAY_SIZE
(
shortpath
));
create_nul_test_file
();
argc
=
winetest_get_mainargs
(
&
argv
);
argc
=
winetest_get_mainargs
(
&
argv
);
if
(
argc
>
2
)
if
(
argc
>
2
)
run_from_file
(
argv
[
2
]);
run_from_file
(
argv
[
2
]);
else
else
EnumResourceNamesA
(
NULL
,
"TESTCMD"
,
test_enum_proc
,
0
);
EnumResourceNamesA
(
NULL
,
"TESTCMD"
,
test_enum_proc
,
0
);
DeleteFileA
(
"nul_test_file"
);
}
}
programs/cmd/tests/test_builtins.cmd
View file @
92e4cad8
...
@@ -1957,6 +1957,9 @@ FOR /F "delims=. tokens=1*" %%A IN (testfile) DO @echo 5:%%A,%%B
...
@@ -1957,6 +1957,9 @@ FOR /F "delims=. tokens=1*" %%A IN (testfile) DO @echo 5:%%A,%%B
FOR /F "delims=. tokens=2*" %%A IN (testfile) DO @echo 6:%%A,%%B
FOR /F "delims=. tokens=2*" %%A IN (testfile) DO @echo 6:%%A,%%B
FOR /F "delims=. tokens=3*" %%A IN (testfile) DO @echo 7:%%A,%%B
FOR /F "delims=. tokens=3*" %%A IN (testfile) DO @echo 7:%%A,%%B
del testfile
del testfile
rem file contains NUL, created by the .exe
for /f %%A in (nul_test_file) DO echo %%A
for /f "tokens=*" %%A in (nul_test_file) DO echo %%A
echo ------------ Testing del ------------
echo ------------ Testing del ------------
echo abc > file
echo abc > file
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
92e4cad8
...
@@ -1315,6 +1315,8 @@ h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
...
@@ -1315,6 +1315,8 @@ h=%h i=b j=c k= l= m=%m n=%n o=%o@or_broken@h=%h i=b j=c k= l= m= n=%n o=%o
4:3.14,%B
4:3.14,%B
5:3,14
5:3,14
6:14,
6:14,
a
a b c
------------ Testing del ------------
------------ Testing del ------------
deleting 'file'
deleting 'file'
errorlevel is 0, good
errorlevel is 0, good
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment