Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/Utils.cpp

Issue 5792731695677440: Fix named pipe security on Windows 7 (Closed)
Patch Set: Refactor to eliminate the corrupt ACL bug. Address comments. Created July 2, 2014, 9:47 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/shared/Communication.cpp ('K') | « src/shared/Communication.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/Utils.cpp
===================================================================
--- a/src/shared/Utils.cpp
+++ b/src/shared/Utils.cpp
@@ -16,22 +16,24 @@
}
+std::unique_ptr<OSVERSIONINFOEX> GetWindowsVersion()
Felix Dahlke 2014/07/03 13:38:07 This seems like a refactoring, can we put it in a
Oleksandr 2014/07/03 13:51:49 It's addressing comments in this review. Shall we
Felix Dahlke 2014/07/03 13:56:33 Which comment? To switch to std::unique_ptr? That
Oleksandr 2014/07/03 14:00:42 http://codereview.adblockplus.org/5792731695677440
+{
+ std::unique_ptr<OSVERSIONINFOEX> osvi(new OSVERSIONINFOEX());
+ osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(osvi.get()));
+ return osvi;
+}
+
bool IsWindowsVistaOrLater()
{
- OSVERSIONINFOEX osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
- return osvi.dwMajorVersion >= 6;
+ std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion();
+ return osvi->dwMajorVersion >= 6;
}
bool IsWindows8OrLater()
{
- OSVERSIONINFOEX osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
- return osvi.dwMajorVersion >= 6 && osvi.dwMinorVersion >= 2;
+ std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion();
+ return (osvi->dwMajorVersion == 6 && osvi->dwMinorVersion >= 2) || osvi->dwMajorVersion > 6;
}
std::string ToUtf8String(const std::wstring& str)
« src/shared/Communication.cpp ('K') | « src/shared/Communication.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld