Commit 63557d57 authored by Dan Kegel's avatar Dan Kegel Committed by Alexandre Julliard

shell32/tests: Avoid buffer overflow during test.

parent 294fe6b6
...@@ -843,8 +843,9 @@ static void test_copy(void) ...@@ -843,8 +843,9 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
/* no double-NULL terminator for pFrom */ /* pFrom contains bogus 2nd name longer than MAX_PATH */
memset(from, 'a', MAX_PATH); memset(from, 'a', MAX_PATH*2);
memset(from+MAX_PATH*2, 0, 2);
lstrcpyA(from, "one.txt"); lstrcpyA(from, "one.txt");
shfo.pFrom = from; shfo.pFrom = from;
shfo.pTo = "two.txt\0"; shfo.pTo = "two.txt\0";
...@@ -856,8 +857,9 @@ static void test_copy(void) ...@@ -856,8 +857,9 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
/* no double-NULL terminator for pTo */ /* pTo contains bogus 2nd name longer than MAX_PATH */
memset(to, 'a', MAX_PATH); memset(to, 'a', MAX_PATH*2);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "two.txt"); lstrcpyA(to, "two.txt");
shfo.pFrom = "one.txt\0"; shfo.pFrom = "one.txt\0";
shfo.pTo = to; shfo.pTo = to;
...@@ -880,9 +882,11 @@ static void test_copy(void) ...@@ -880,9 +882,11 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
/* no double-NULL terminator for pFrom and pTo */ /* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */
memset(from, 'a', MAX_PATH); memset(from, 'a', MAX_PATH*2);
memset(to, 'a', MAX_PATH); 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(from, "one.txt");
lstrcpyA(to, "two.txt"); lstrcpyA(to, "two.txt");
shfo.pFrom = from; shfo.pFrom = from;
...@@ -895,8 +899,9 @@ static void test_copy(void) ...@@ -895,8 +899,9 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
/* no double-NULL terminator for pTo, FOF_MULTIDESTFILES */ /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */
memset(to, 'a', MAX_PATH); memset(to, 'a', MAX_PATH*2);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "two.txt"); lstrcpyA(to, "two.txt");
shfo.pFrom = "one.txt\0"; shfo.pFrom = "one.txt\0";
shfo.pTo = to; shfo.pTo = to;
...@@ -910,11 +915,12 @@ static void test_copy(void) ...@@ -910,11 +915,12 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
createTestFile("two.txt"); createTestFile("two.txt");
/* no double-NULL terminator for pTo, /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, * multiple source files,
* dest directory does not exist * dest directory does not exist
*/ */
memset(to, 'a', 2 * MAX_PATH); memset(to, 'a', 2 * MAX_PATH);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir"); lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0"; shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to; shfo.pTo = to;
...@@ -932,11 +938,12 @@ static void test_copy(void) ...@@ -932,11 +938,12 @@ static void test_copy(void)
createTestFile("two.txt"); createTestFile("two.txt");
CreateDirectoryA("threedir", NULL); CreateDirectoryA("threedir", NULL);
/* no double-NULL terminator for pTo, /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, * multiple source files,
* dest directory does exist * dest directory does exist
*/ */
memset(to, 'a', 2 * MAX_PATH); memset(to, 'a', 2 * MAX_PATH);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir"); lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0"; shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to; shfo.pTo = to;
...@@ -952,11 +959,12 @@ static void test_copy(void) ...@@ -952,11 +959,12 @@ static void test_copy(void)
createTestFile("one.txt"); createTestFile("one.txt");
createTestFile("two.txt"); createTestFile("two.txt");
/* no double-NULL terminator for pTo, /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, FOF_MULTIDESTFILES * multiple source files, FOF_MULTIDESTFILES
* dest dir does not exist * dest dir does not exist
*/ */
memset(to, 'a', 2 * MAX_PATH); memset(to, 'a', 2 * MAX_PATH);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir"); lstrcpyA(to, "threedir");
shfo.pFrom = "one.txt\0two.txt\0"; shfo.pFrom = "one.txt\0two.txt\0";
shfo.pTo = to; shfo.pTo = to;
...@@ -979,11 +987,12 @@ static void test_copy(void) ...@@ -979,11 +987,12 @@ static void test_copy(void)
createTestFile("two.txt"); createTestFile("two.txt");
CreateDirectoryA("threedir", NULL); CreateDirectoryA("threedir", NULL);
/* no double-NULL terminator for pTo, /* pTo contains bogus 2nd name longer than MAX_PATH,
* multiple source files, FOF_MULTIDESTFILES * multiple source files, FOF_MULTIDESTFILES
* dest dir does exist * dest dir does exist
*/ */
memset(to, 'a', 2 * MAX_PATH); memset(to, 'a', 2 * MAX_PATH);
memset(to+MAX_PATH*2, 0, 2);
lstrcpyA(to, "threedir"); lstrcpyA(to, "threedir");
ptr = to + lstrlenA(to) + 1; ptr = to + lstrlenA(to) + 1;
lstrcpyA(ptr, "fourdir"); lstrcpyA(ptr, "fourdir");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment