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
766dc670
Commit
766dc670
authored
Jul 06, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/tests: Rewrite replace_escaped_spaces to avoid overflows.
Spotted by Marcus Meissner.
parent
7a21d062
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
batch.c
programs/cmd/tests/batch.c
+9
-19
No files found.
programs/cmd/tests/batch.c
View file @
766dc670
...
...
@@ -29,29 +29,19 @@ static DWORD workdir_len;
static
const
char
*
replace_escaped_spaces
(
const
char
*
data
,
DWORD
size
,
DWORD
*
new_size
)
{
static
const
char
escaped_space
[]
=
{
'@'
,
's'
,
'p'
,
'a'
,
'c'
,
'e'
,
'@'
,
'\0'
};
const
char
*
a
,
*
b
;
char
*
new_data
;
DWORD
len_space
=
sizeof
(
escaped_space
)
-
1
;
char
*
ptr
,
*
new_data
;
a
=
b
=
data
;
*
new_size
=
0
;
new_data
=
ptr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
+
1
);
memcpy
(
new_data
,
data
,
size
);
new_data
[
size
]
=
0
;
new_data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
char
));
ok
(
new_data
!=
NULL
,
"HeapAlloc failed
\n
"
);
if
(
!
new_data
)
return
NULL
;
while
(
(
b
=
strstr
(
a
,
escaped_space
))
)
while
((
ptr
=
strstr
(
ptr
,
escaped_space
)))
{
strncpy
(
new_data
+
*
new_size
,
a
,
b
-
a
+
1
);
*
new_size
+=
b
-
a
+
1
;
new_data
[
*
new_size
-
1
]
=
' '
;
a
=
b
+
len_space
;
char
*
end
=
ptr
+
sizeof
(
escaped_space
)
-
1
;
*
ptr
++
=
' '
;
memmove
(
ptr
,
end
,
strlen
(
end
)
+
1
);
}
strncpy
(
new_data
+
*
new_size
,
a
,
strlen
(
a
)
+
1
);
*
new_size
+=
strlen
(
a
);
*
new_size
=
strlen
(
new_data
);
return
new_data
;
}
...
...
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