Dan Kegel : shell32/tests: Avoid buffer overflow during test.
Alexandre Julliard
julliard at winehq.org
Tue Jun 10 13:35:24 CDT 2008
Module: wine
Branch: master
Commit: 63557d572c2f3c20acbb48a8284f7ec2945ffd05
URL: http://source.winehq.org/git/wine.git/?a=commit;h=63557d572c2f3c20acbb48a8284f7ec2945ffd05
Author: Dan Kegel <dank at kegel.com>
Date: Tue Jun 10 06:07:20 2008 -0700
shell32/tests: Avoid buffer overflow during test.
---
dlls/shell32/tests/shlfileop.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index df4bd41..30d3f24 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -843,8 +843,9 @@ static void test_copy(void)
createTestFile("one.txt");
- /* no double-NULL terminator for pFrom */
- memset(from, 'a', MAX_PATH);
+ /* pFrom contains bogus 2nd name longer than MAX_PATH */
+ memset(from, 'a', MAX_PATH*2);
+ memset(from+MAX_PATH*2, 0, 2);
lstrcpyA(from, "one.txt");
shfo.pFrom = from;
shfo.pTo = "two.txt\0";
@@ -856,8 +857,9 @@ static void test_copy(void)
createTestFile("one.txt");
- /* no double-NULL terminator for pTo */
- memset(to, 'a', MAX_PATH);
+ /* pTo contains bogus 2nd name longer than MAX_PATH */
+ memset(to, 'a', MAX_PATH*2);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "two.txt");
shfo.pFrom = "one.txt\0";
shfo.pTo = to;
@@ -880,9 +882,11 @@ static void test_copy(void)
createTestFile("one.txt");
- /* no double-NULL terminator for pFrom and pTo */
- memset(from, 'a', MAX_PATH);
- memset(to, 'a', MAX_PATH);
+ /* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */
+ memset(from, 'a', MAX_PATH*2);
+ memset(from+MAX_PATH*2, 0, 2);
+ memset(to, 'a', MAX_PATH*2);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(from, "one.txt");
lstrcpyA(to, "two.txt");
shfo.pFrom = from;
@@ -895,8 +899,9 @@ static void test_copy(void)
createTestFile("one.txt");
- /* no double-NULL terminator for pTo, FOF_MULTIDESTFILES */
- memset(to, 'a', MAX_PATH);
+ /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */
+ memset(to, 'a', MAX_PATH*2);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "two.txt");
shfo.pFrom = "one.txt\0";
shfo.pTo = to;
@@ -910,11 +915,12 @@ static void test_copy(void)
createTestFile("one.txt");
createTestFile("two.txt");
- /* no double-NULL terminator for pTo,
+ /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files,
* dest directory does not exist
*/
memset(to, 'a', 2 * MAX_PATH);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to;
@@ -932,11 +938,12 @@ static void test_copy(void)
createTestFile("two.txt");
CreateDirectoryA("threedir", NULL);
- /* no double-NULL terminator for pTo,
+ /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files,
* dest directory does exist
*/
memset(to, 'a', 2 * MAX_PATH);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to;
@@ -952,11 +959,12 @@ static void test_copy(void)
createTestFile("one.txt");
createTestFile("two.txt");
- /* no double-NULL terminator for pTo,
+ /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, FOF_MULTIDESTFILES
* dest dir does not exist
*/
memset(to, 'a', 2 * MAX_PATH);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to;
@@ -979,11 +987,12 @@ static void test_copy(void)
createTestFile("two.txt");
CreateDirectoryA("threedir", NULL);
- /* no double-NULL terminator for pTo,
+ /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, FOF_MULTIDESTFILES
* dest dir does exist
*/
memset(to, 'a', 2 * MAX_PATH);
+ memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir");
ptr = to + lstrlenA(to) + 1;
lstrcpyA(ptr, "fourdir");
More information about the wine-cvs
mailing list