Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
5f9f260e
Commit
5f9f260e
authored
Feb 01, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Avoid truncating the output buffer length in GetCurrentDirectoryA.
parent
76e5c012
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
path.c
dlls/kernel32/path.c
+1
-1
path.c
dlls/kernel32/tests/path.c
+30
-0
No files found.
dlls/kernel32/path.c
View file @
5f9f260e
...
...
@@ -76,7 +76,7 @@ static DWORD copy_filename_WtoA( LPCWSTR nameW, LPSTR buffer, DWORD len )
ANSI_STRING
str
;
str
.
Buffer
=
buffer
;
str
.
MaximumLength
=
len
;
str
.
MaximumLength
=
min
(
len
,
UNICODE_STRING_MAX_CHARS
)
;
if
(
is_ansi
)
RtlUnicodeStringToAnsiString
(
&
str
,
&
strW
,
FALSE
);
else
...
...
dlls/kernel32/tests/path.c
View file @
5f9f260e
...
...
@@ -423,6 +423,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
static
void
test_CurrentDirectoryA
(
CHAR
*
origdir
,
CHAR
*
newdir
)
{
CHAR
tmpstr
[
MAX_PATH
],
tmpstr1
[
MAX_PATH
];
char
*
buffer
;
DWORD
len
,
len1
;
/* Save the original directory, so that we can return to it at the end
of the test
...
...
@@ -437,6 +438,35 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
ok
(
len1
==
len
+
1
,
"GetCurrentDirectoryA returned %d instead of %d
\n
"
,
len1
,
len
+
1
);
ok
(
lstrcmpiA
(
tmpstr
,
"aaaaaaa"
)
==
0
,
"GetCurrentDirectoryA should not have modified the buffer
\n
"
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
2
*
65536
);
SetLastError
(
0xdeadbeef
);
strcpy
(
buffer
,
"foo"
);
len
=
GetCurrentDirectoryA
(
32767
,
buffer
);
ok
(
len
!=
0
&&
len
<
MAX_PATH
,
"GetCurrentDirectoryA failed %u err %u
\n
"
,
len
,
GetLastError
()
);
if
(
len
)
ok
(
!
strcmp
(
buffer
,
origdir
),
"wrong result %s
\n
"
,
buffer
);
SetLastError
(
0xdeadbeef
);
strcpy
(
buffer
,
"foo"
);
len
=
GetCurrentDirectoryA
(
32768
,
buffer
);
ok
(
len
!=
0
&&
len
<
MAX_PATH
,
"GetCurrentDirectoryA failed %u err %u
\n
"
,
len
,
GetLastError
()
);
if
(
len
)
ok
(
!
strcmp
(
buffer
,
origdir
),
"wrong result %s
\n
"
,
buffer
);
SetLastError
(
0xdeadbeef
);
strcpy
(
buffer
,
"foo"
);
len
=
GetCurrentDirectoryA
(
65535
,
buffer
);
ok
(
(
len
!=
0
&&
len
<
MAX_PATH
)
||
broken
(
!
len
),
/* nt4, win2k, xp */
"GetCurrentDirectoryA failed %u err %u
\n
"
,
len
,
GetLastError
()
);
if
(
len
)
ok
(
!
strcmp
(
buffer
,
origdir
),
"wrong result %s
\n
"
,
buffer
);
SetLastError
(
0xdeadbeef
);
strcpy
(
buffer
,
"foo"
);
len
=
GetCurrentDirectoryA
(
65536
,
buffer
);
ok
(
(
len
!=
0
&&
len
<
MAX_PATH
)
||
broken
(
!
len
),
/* nt4 */
"GetCurrentDirectoryA failed %u err %u
\n
"
,
len
,
GetLastError
()
);
if
(
len
)
ok
(
!
strcmp
(
buffer
,
origdir
),
"wrong result %s
\n
"
,
buffer
);
SetLastError
(
0xdeadbeef
);
strcpy
(
buffer
,
"foo"
);
len
=
GetCurrentDirectoryA
(
2
*
65536
,
buffer
);
ok
(
(
len
!=
0
&&
len
<
MAX_PATH
)
||
broken
(
!
len
),
/* nt4 */
"GetCurrentDirectoryA failed %u err %u
\n
"
,
len
,
GetLastError
()
);
if
(
len
)
ok
(
!
strcmp
(
buffer
,
origdir
),
"wrong result %s
\n
"
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
/* SetCurrentDirectoryA shouldn't care whether the string has a
trailing '\\' or not
*/
...
...
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