Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: sandbox/win/src/process_mitigations_test.cc

Issue 2404823002: Fix error handling in POSIX version of the base::File::GetLength. (Closed)
Patch Set: Fix error handling in POSIX version of the base::File::GetLength. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/win/src/process_mitigations.h" 5 #include "sandbox/win/src/process_mitigations.h"
6 6
7 #include <d3d9.h> 7 #include <d3d9.h>
8 #include <initguid.h> 8 #include <initguid.h>
9 #include <opmapi.h> 9 #include <opmapi.h>
10 #include <psapi.h> 10 #include <psapi.h>
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1529
1530 // Open font file passed in as an argument. 1530 // Open font file passed in as an argument.
1531 base::File file(base::FilePath(argv[0]), 1531 base::File file(base::FilePath(argv[0]),
1532 base::File::FLAG_OPEN | base::File::FLAG_READ); 1532 base::File::FLAG_OPEN | base::File::FLAG_READ);
1533 if (!file.IsValid()) 1533 if (!file.IsValid())
1534 // Failed to open the font file passed in. 1534 // Failed to open the font file passed in.
1535 return SBOX_TEST_NOT_FOUND; 1535 return SBOX_TEST_NOT_FOUND;
1536 1536
1537 std::vector<char> font_data; 1537 std::vector<char> font_data;
1538 int64_t len = file.GetLength(); 1538 int64_t len = file.GetLength();
1539 if (len < 0)
1540 return SBOX_TEST_NOT_FOUND;
1539 font_data.resize(len); 1541 font_data.resize(len);
1540 1542
1541 int read = file.Read(0, &font_data[0], len); 1543 int read = file.Read(0, &font_data[0], len);
1542 file.Close(); 1544 file.Close();
1543 1545
1544 if (read != len) 1546 if (read != len)
1545 return SBOX_TEST_NOT_FOUND; 1547 return SBOX_TEST_NOT_FOUND;
1546 1548
1547 DWORD font_count = 0; 1549 DWORD font_count = 0;
1548 HANDLE font_handle = add_font_mem_resource( 1550 HANDLE font_handle = add_font_mem_resource(
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 cmd = cmd.Append(L"calc.exe"); 1805 cmd = cmd.Append(L"calc.exe");
1804 1806
1805 std::wstring test_command(base::StringPrintf(L"TestChildProcess %ls 0x%08X", 1807 std::wstring test_command(base::StringPrintf(L"TestChildProcess %ls 0x%08X",
1806 cmd.value().c_str(), 1808 cmd.value().c_str(),
1807 STATUS_ACCESS_VIOLATION)); 1809 STATUS_ACCESS_VIOLATION));
1808 1810
1809 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(test_command.c_str())); 1811 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(test_command.c_str()));
1810 } 1812 }
1811 1813
1812 } // namespace sandbox 1814 } // namespace sandbox
OLDNEW
« net/disk_cache/blockfile/mapped_file_posix.cc ('K') | « net/disk_cache/simple/simple_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698