From 9eb7b11b614e987d7608678d0396873f37ca817e Mon Sep 17 00:00:00 2001 From: "wez@chromium.org" Date: Wed, 28 Mar 2012 20:19:31 +0000 Subject: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. This primarily addresses issues with code using the OS-provided htonX() & ntohX() functions from within the Chrome sandbox. Under Windows these functions are provided by ws2_32.dll, which is no longer available within Chrome's sandbox. The new base::HostToNetXX() and NetToHostXX() functions are safe for use by sandboxed code on Windows, and provide a single place where future fixes for other platforms can be made. BUG=117252 Review URL: http://codereview.chromium.org/9716020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129476 0039d316-1c4b-4281-b951-d872f2087c98 --- sync/util/nigori.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sync') diff --git a/sync/util/nigori.cc b/sync/util/nigori.cc index 1b0e3c1..0b96b37 100644 --- a/sync/util/nigori.cc +++ b/sync/util/nigori.cc @@ -31,7 +31,7 @@ class NigoriStream { // Append the big-endian representation of the length of |value| with 32 bits, // followed by |value| itself to the stream. NigoriStream& operator<<(const std::string& value) { - uint32 size = htonl(value.size()); + uint32 size = base::HostToNet32(value.size()); stream_.write((char *) &size, sizeof(uint32)); stream_ << value; return *this; @@ -41,9 +41,9 @@ class NigoriStream { // followed by the big-endian representation of the value of |type|, with 32 // bits, to the stream. NigoriStream& operator<<(const Nigori::Type type) { - uint32 size = htonl(sizeof(uint32)); + uint32 size = base::HostToNet32(sizeof(uint32)); stream_.write((char *) &size, sizeof(uint32)); - uint32 value = htonl(type); + uint32 value = base::HostToNet32(type); stream_.write((char *) &value, sizeof(uint32)); return *this; } -- cgit v1.1