Avoid loading ws2_32.dll just to get htons() and friends.
Chrome does not load ws2_32.dll into the renderer sandbox, so code calling these functions would fail attempting to load the DLL. This CL replaces the calls with direct use of the MSVC byte-swap intrinsics. BUG=115477,116591 TEST=Chromoting client does not crash on connect on Windows. Review URL: http://codereview.chromium.org/9614004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125110 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -13,6 +13,14 @@
|
||||
|
||||
#include "base/sys_byteorder.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Allow htonl/ntohl to be called without requiring ws2_32.dll to be loaded,
|
||||
// which isn't available in Chrome's sandbox. See crbug.com/116591.
|
||||
// TODO(wez): Replace these calls with base::htonl() etc when available.
|
||||
#define ntohl(x) _byteswap_ulong(x)
|
||||
#define htonl(x) _byteswap_ulong(x)
|
||||
#endif // OS_WIN
|
||||
|
||||
namespace {
|
||||
|
||||
// Field element functions.
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "base/stringprintf.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
#include "base/sys_byteorder.h"
|
||||
#include "base/time.h"
|
||||
#include "base/utf_offset_string_conversions.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
@ -75,6 +76,14 @@
|
||||
|
||||
using base::Time;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Allow htons/ntohs to be called without requiring ws2_32.dll to be loaded,
|
||||
// which isn't available in Chrome's sandbox. See crbug.com/116591.
|
||||
// TODO(wez): Replace these calls with base::htons() etc when available.
|
||||
#define ntohs(x) _byteswap_ushort(x)
|
||||
#define htons(x) _byteswap_ushort(x)
|
||||
#endif // OS_WIN
|
||||
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
Reference in New Issue
Block a user