From f4dca79bcaa251f18d504a81766e3f5a6397ba43 Mon Sep 17 00:00:00 2001 From: Selim Gurun Date: Thu, 24 May 2012 14:28:47 -0700 Subject: Modify Makefile for building for ASAN Change-Id: I18fe150f994d9217d0526660b1cac781fdac92cb --- Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Android.mk b/Android.mk index 7d1034e..4863e57 100644 --- a/Android.mk +++ b/Android.mk @@ -487,4 +487,9 @@ LOCAL_PRELINK_MODULE := false # Including this will modify the include path include external/stlport/libstlport.mk +ifneq ($(strip $(WITH_ADDRESS_SANITIZER)),) + LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/asan + LOCAL_ADDRESS_SANITIZER := true +endif + include $(BUILD_SHARED_LIBRARY) -- cgit v1.1 From edec5f424996d4a532ba6fdb2203c06a02887606 Mon Sep 17 00:00:00 2001 From: Selim Gurun Date: Tue, 5 Jun 2012 18:18:30 -0700 Subject: Convert exit calls to abort for Android Bug: 6603427 This is to track some silent failures happening in mediaserver. Change-Id: I9345cee5e0137b723fd5a2b7c787c235af4462b8 --- base/process_util_posix.cc | 36 ++++++++++++++++++++++++++++++++++++ net/disk_cache/rankings.cc | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 47f04a9..3270079 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -155,7 +155,11 @@ void StackDumpSignalHandler(int signal, siginfo_t* info, ucontext_t* context) { write(STDERR_FILENO, buf, std::min(len, sizeof(buf) - 1)); #endif // ARCH_CPU_32_BITS #endif // defined(OS_MACOSX) +#ifdef ANDROID + abort(); +#else _exit(1); +#endif } void ResetChildSignalHandlersToDefaults() { @@ -529,14 +533,22 @@ bool LaunchAppImpl( int null_fd = HANDLE_EINTR(open("/dev/null", O_RDONLY)); if (null_fd < 0) { RAW_LOG(ERROR, "Failed to open /dev/null"); +#ifdef ANDROID + abort(); +#else _exit(127); +#endif } file_util::ScopedFD null_fd_closer(&null_fd); int new_fd = HANDLE_EINTR(dup2(null_fd, STDIN_FILENO)); if (new_fd != STDIN_FILENO) { RAW_LOG(ERROR, "Failed to dup /dev/null for stdin"); +#ifdef ANDROID + abort(); +#else _exit(127); +#endif } if (start_new_process_group) { @@ -544,7 +556,11 @@ bool LaunchAppImpl( // starts off a new process group with pgid equal to its process ID. if (setpgid(0, 0) < 0) { RAW_LOG(ERROR, "setpgid failed"); +#ifdef ANDROID + abort(); +#else _exit(127); +#endif } } #if defined(OS_MACOSX) @@ -575,7 +591,11 @@ bool LaunchAppImpl( // fd_shuffle1 is mutated by this call because it cannot malloc. if (!ShuffleFileDescriptors(&fd_shuffle1)) +#ifdef ANDROID + abort(); +#else _exit(127); +#endif CloseSuperfluousFds(fd_shuffle2); @@ -585,7 +605,11 @@ bool LaunchAppImpl( execvp(argv_cstr[0], argv_cstr.get()); RAW_LOG(ERROR, "LaunchApp: failed to execvp:"); RAW_LOG(ERROR, argv_cstr[0]); +#ifdef ANDROID + abort(); +#else _exit(127); +#endif } else { // Parent process if (wait) { @@ -891,7 +915,11 @@ static bool GetAppOutputInternal(const CommandLine& cl, char* const envp[], // in the child. int dev_null = open("/dev/null", O_WRONLY); if (dev_null < 0) +#ifdef ANDROID + abort(); +#else _exit(127); +#endif fd_shuffle1.push_back(InjectionArc(pipe_fd[1], STDOUT_FILENO, true)); fd_shuffle1.push_back(InjectionArc(dev_null, STDERR_FILENO, true)); @@ -903,7 +931,11 @@ static bool GetAppOutputInternal(const CommandLine& cl, char* const envp[], std::back_inserter(fd_shuffle2)); if (!ShuffleFileDescriptors(&fd_shuffle1)) +#ifdef ANDROID + abort(); +#else _exit(127); +#endif CloseSuperfluousFds(fd_shuffle2); @@ -914,7 +946,11 @@ static bool GetAppOutputInternal(const CommandLine& cl, char* const envp[], execvp(argv_cstr[0], argv_cstr.get()); else execve(argv_cstr[0], argv_cstr.get(), envp); +#ifdef ANDROID + abort(); +#else _exit(127); +#endif } default: // parent { diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc index 902db1c..11c91d3 100644 --- a/net/disk_cache/rankings.cc +++ b/net/disk_cache/rankings.cc @@ -71,10 +71,14 @@ void TerminateSelf() { // Windows does more work on _exit() than we would like, so we force exit. TerminateProcess(GetCurrentProcess(), 0); #elif defined(OS_POSIX) +#if defined(ANDROID) + abort(); +#else // On POSIX, _exit() will terminate the process with minimal cleanup, // and it is cleaner than killing. _exit(0); #endif +#endif } #endif // NDEBUG -- cgit v1.1 From 95b2bad159f2dbca0555e82f156db8424b75c2b8 Mon Sep 17 00:00:00 2001 From: Jonathan Dixon Date: Wed, 6 Jun 2012 17:47:18 -0700 Subject: Work around for use-after-free cert bug Holds a strong references in the cert cache. This is a simpler alternative to full backport of upstream fix, from http://crrev.com/92977 -- see bug for more details. BUG: 6508448 Change-Id: Ib47ca2e33b9e43ac47baf645069ecaab257ec74a --- net/base/x509_certificate.cc | 55 ++++++++++++++++++++---------------- net/base/x509_certificate.h | 10 +++---- net/base/x509_certificate_openssl.cc | 2 +- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc index f041061..8183fc3 100644 --- a/net/base/x509_certificate.cc +++ b/net/base/x509_certificate.cc @@ -54,14 +54,14 @@ const char kPKCS7Header[] = "PKCS7"; // will be holding dead pointers to the objects). // TODO(rsleevi): There exists a chance of a use-after-free, due to a race // between Find() and Remove(). See http://crbug.com/49377 +// ANDROID: we removed Remove(), to attempt to fix this. See http://b/6508448 class X509CertificateCache { public: void Insert(X509Certificate* cert); - void Remove(X509Certificate* cert); - X509Certificate* Find(const SHA1Fingerprint& fingerprint); + scoped_refptr Find(const SHA1Fingerprint& fingerprint); private: - typedef std::map + typedef std::map, SHA1FingerprintLessThan> CertMap; // Obtain an instance of X509CertificateCache via a LazyInstance. @@ -90,23 +90,29 @@ void X509CertificateCache::Insert(X509Certificate* cert) { DCHECK(!IsNullFingerprint(cert->fingerprint())) << "Only insert certs with real fingerprints."; + // Sanity test: never cache more than 50 certs + while (cache_.size() >= 50) + cache_.erase(cache_.begin()); + cache_[cert->fingerprint()] = cert; -}; -// Remove |cert| from the cache. The cache does not assume that |cert| is -// already in the cache. -void X509CertificateCache::Remove(X509Certificate* cert) { - base::AutoLock lock(lock_); + // Trim the cache if there are unused certs remaining. Aim to hold between + // 10 and 20 certs in the cache in normal usage. + if (cache_.size() <= 20) // high water mark + return; - CertMap::iterator pos(cache_.find(cert->fingerprint())); - if (pos == cache_.end()) - return; // It is not an error to remove a cert that is not in the cache. - cache_.erase(pos); + for (CertMap::iterator it = cache_.begin(); it != cache_.end(); ++it) { + if (it->second->HasOneRef()) { + cache_.erase(it); + if (cache_.size() <= 10) // low water mark + return; + } + } }; // Find a certificate in the cache with the given fingerprint. If one does // not exist, this method returns NULL. -X509Certificate* X509CertificateCache::Find( +scoped_refptr X509CertificateCache::Find( const SHA1Fingerprint& fingerprint) { base::AutoLock lock(lock_); @@ -148,7 +154,7 @@ X509Certificate::X509Certificate(const std::string& subject, } // static -X509Certificate* X509Certificate::CreateFromHandle( +scoped_refptr X509Certificate::CreateFromHandle( OSCertHandle cert_handle, Source source, const OSCertHandles& intermediates) { @@ -157,7 +163,7 @@ X509Certificate* X509Certificate::CreateFromHandle( // Check if we already have this certificate in memory. X509CertificateCache* cache = g_x509_certificate_cache.Pointer(); - X509Certificate* cached_cert = + scoped_refptr cached_cert = cache->Find(CalculateFingerprint(cert_handle)); if (cached_cert) { DCHECK(cached_cert->source_ != SOURCE_UNUSED); @@ -172,8 +178,8 @@ X509Certificate* X509Certificate::CreateFromHandle( } // Otherwise, allocate and cache a new object. - X509Certificate* cert = new X509Certificate(cert_handle, source, - intermediates); + scoped_refptr cert = new X509Certificate(cert_handle, source, + intermediates); cache->Insert(cert); return cert; } @@ -195,7 +201,7 @@ static X509Certificate::OSCertHandle CreateOSCert(base::StringPiece der_cert) { #endif // static -X509Certificate* X509Certificate::CreateFromDERCertChain( +scoped_refptr X509Certificate::CreateFromDERCertChain( const std::vector& der_certs) { if (der_certs.empty()) return NULL; @@ -209,7 +215,7 @@ X509Certificate* X509Certificate::CreateFromDERCertChain( OSCertHandle handle = CreateOSCert(der_certs[0]); DCHECK(handle); - X509Certificate* cert = + scoped_refptr cert = CreateFromHandle(handle, SOURCE_FROM_NETWORK, intermediate_ca_certs); FreeOSCertHandle(handle); for (size_t i = 0; i < intermediate_ca_certs.size(); i++) @@ -219,13 +225,13 @@ X509Certificate* X509Certificate::CreateFromDERCertChain( } // static -X509Certificate* X509Certificate::CreateFromBytes(const char* data, +scoped_refptr X509Certificate::CreateFromBytes(const char* data, int length) { OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); if (!cert_handle) return NULL; - X509Certificate* cert = CreateFromHandle(cert_handle, + scoped_refptr cert = CreateFromHandle(cert_handle, SOURCE_LONE_CERT_IMPORT, OSCertHandles()); FreeOSCertHandle(cert_handle); @@ -233,7 +239,7 @@ X509Certificate* X509Certificate::CreateFromBytes(const char* data, } // static -X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, +scoped_refptr X509Certificate::CreateFromPickle(const Pickle& pickle, void** pickle_iter, PickleType type) { OSCertHandle cert_handle = ReadCertHandleFromPickle(pickle, pickle_iter); @@ -268,7 +274,7 @@ X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, if (!cert_handle) return NULL; - X509Certificate* cert = CreateFromHandle(cert_handle, SOURCE_FROM_CACHE, + scoped_refptr cert = CreateFromHandle(cert_handle, SOURCE_FROM_CACHE, intermediates); FreeOSCertHandle(cert_handle); for (size_t i = 0; i < intermediates.size(); ++i) @@ -346,7 +352,7 @@ CertificateList X509Certificate::CreateCertificateListFromBytes( for (OSCertHandles::iterator it = certificates.begin(); it != certificates.end(); ++it) { - X509Certificate* result = CreateFromHandle(*it, SOURCE_LONE_CERT_IMPORT, + scoped_refptr result = CreateFromHandle(*it, SOURCE_LONE_CERT_IMPORT, OSCertHandles()); results.push_back(scoped_refptr(result)); FreeOSCertHandle(*it); @@ -539,7 +545,6 @@ X509Certificate::X509Certificate(OSCertHandle cert_handle, X509Certificate::~X509Certificate() { // We might not be in the cache, but it is safe to remove ourselves anyway. - g_x509_certificate_cache.Get().Remove(this); if (cert_handle_) FreeOSCertHandle(cert_handle_); for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) diff --git a/net/base/x509_certificate.h b/net/base/x509_certificate.h index 89865cc..a66fad9 100644 --- a/net/base/x509_certificate.h +++ b/net/base/x509_certificate.h @@ -137,7 +137,7 @@ class NET_EXPORT X509Certificate : public base::RefCountedThreadSafe. - static X509Certificate* CreateFromHandle(OSCertHandle cert_handle, + static scoped_refptr CreateFromHandle(OSCertHandle cert_handle, Source source, const OSCertHandles& intermediates); @@ -147,14 +147,14 @@ class NET_EXPORT X509Certificate : public base::RefCountedThreadSafe. - static X509Certificate* CreateFromDERCertChain( + static scoped_refptr CreateFromDERCertChain( const std::vector& der_certs); // Create an X509Certificate from the DER-encoded representation. // Returns NULL on failure. // // The returned pointer must be stored in a scoped_refptr. - static X509Certificate* CreateFromBytes(const char* data, int length); + static scoped_refptr CreateFromBytes(const char* data, int length); // Create an X509Certificate from the representation stored in the given // pickle. The data for this object is found relative to the given @@ -162,7 +162,7 @@ class NET_EXPORT X509Certificate : public base::RefCountedThreadSafe. - static X509Certificate* CreateFromPickle(const Pickle& pickle, + static scoped_refptr CreateFromPickle(const Pickle& pickle, void** pickle_iter, PickleType type); @@ -192,7 +192,7 @@ class NET_EXPORT X509Certificate : public base::RefCountedThreadSafe CreateSelfSigned(crypto::RSAPrivateKey* key, const std::string& subject, uint32 serial_number, base::TimeDelta valid_duration); diff --git a/net/base/x509_certificate_openssl.cc b/net/base/x509_certificate_openssl.cc index aecf75d..e541b34 100644 --- a/net/base/x509_certificate_openssl.cc +++ b/net/base/x509_certificate_openssl.cc @@ -385,7 +385,7 @@ X509Certificate::OSCertHandles X509Certificate::CreateOSCertHandlesFromBytes( } // static -X509Certificate* X509Certificate::CreateSelfSigned( +scoped_refptr X509Certificate::CreateSelfSigned( crypto::RSAPrivateKey* key, const std::string& subject, uint32 serial_number, -- cgit v1.1 From 516fd388674362c6fb2de59340b85f3d92ea32d8 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 11 Jul 2012 18:07:43 +0200 Subject: Forward-compatible fix for ucontext_t The Android C library will soon be modified to declare ucontext_t in . To avoid conflicts when this happens, only define the type when needed. See b/issue?id=2189142 Change-Id: I297b8e6f9fba8fb99c5f799b0d7e7f4dbda914bb --- base/process_util_posix.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 3270079..a741892 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -39,8 +39,8 @@ extern char** environ; #endif -#ifdef ANDROID -// No ucontext.h on Android +#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) +// No ucontext.h on old Android C library headers typedef void ucontext_t; #endif -- cgit v1.1 From 7dd039766e8bea164f5e14cb9ab26c59d3b9a5bd Mon Sep 17 00:00:00 2001 From: Paul Lind Date: Fri, 3 Aug 2012 08:54:28 -0700 Subject: Add MIPS architecture support Change-Id: Id2c3f41edee0e1c73cb084666533802bcf117876 Signed-off-by: Douglas Leung Signed-off-by: Chris Dearman --- base/atomicops.h | 2 + base/atomicops_internals_mips_gcc.h | 162 ++++++++++++++++++++++++++++ base/debug/debugger_posix.cc | 2 + build/build_config.h | 5 + net/http/http_auth_handler_ntlm_portable.cc | 6 +- 5 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 base/atomicops_internals_mips_gcc.h diff --git a/base/atomicops.h b/base/atomicops.h index 5b2b9dd..ef7fc02 100644 --- a/base/atomicops.h +++ b/base/atomicops.h @@ -141,6 +141,8 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); #include "base/atomicops_internals_x86_gcc.h" #elif defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY) #include "base/atomicops_internals_arm_gcc.h" +#elif defined(COMPILER_GCC) && defined(ARCH_CPU_MIPS_FAMILY) +#include "base/atomicops_internals_mips_gcc.h" #else #error "Atomic operations are not supported on your platform" #endif diff --git a/base/atomicops_internals_mips_gcc.h b/base/atomicops_internals_mips_gcc.h new file mode 100644 index 0000000..2bcddf7 --- /dev/null +++ b/base/atomicops_internals_mips_gcc.h @@ -0,0 +1,162 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is an internal atomic implementation, use base/atomicops.h instead. +// +// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears. + +#ifndef BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_ +#define BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_ +#pragma once + +#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") + +namespace base { +namespace subtle { + +// Atomically execute: +// result = *ptr; +// if (*ptr == old_value) +// *ptr = new_value; +// return result; +// +// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value". +// Always return the old value of "*ptr" +// +// This routine implies no memory barriers. +inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + Atomic32 prev, tmp; + __asm__ __volatile__(".set push\n" + ".set noreorder\n" + "1:\n" + "ll %0, %5\n" // prev = *ptr + "bne %0, %3, 2f\n" // if (prev != old_value) goto 2 + "move %2, %4\n" // tmp = new_value + "sc %2, %1\n" // *ptr = tmp (with atomic check) + "beqz %2, 1b\n" // start again on atomic error + "nop\n" // delay slot nop + "2:\n" + ".set pop\n" + : "=&r" (prev), "=m" (*ptr), "=&r" (tmp) + : "Ir" (old_value), "r" (new_value), "m" (*ptr) + : "memory"); + return prev; +} + +// Atomically store new_value into *ptr, returning the previous value held in +// *ptr. This routine implies no memory barriers. +inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, + Atomic32 new_value) { + Atomic32 temp, old; + __asm__ __volatile__(".set push\n" + ".set noreorder\n" + "1:\n" + "ll %1, %2\n" // old = *ptr + "move %0, %3\n" // temp = new_value + "sc %0, %2\n" // *ptr = temp (with atomic check) + "beqz %0, 1b\n" // start again on atomic error + "nop\n" // delay slot nop + ".set pop\n" + : "=&r" (temp), "=&r" (old), "=m" (*ptr) + : "r" (new_value), "m" (*ptr) + : "memory"); + + return old; +} + +// Atomically increment *ptr by "increment". Returns the new value of +// *ptr with the increment applied. This routine implies no memory barriers. +inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + Atomic32 temp, temp2; + + __asm__ __volatile__(".set push\n" + ".set noreorder\n" + "1:\n" + "ll %0, %2\n" // temp = *ptr + "addu %1, %0, %3\n" // temp2 = temp + increment + "sc %1, %2\n" // *ptr = temp2 (with atomic check) + "beqz %1, 1b\n" // start again on atomic error + "addu %1, %0, %3\n" // temp2 = temp + increment + ".set pop\n" + : "=&r" (temp), "=&r" (temp2), "=m" (*ptr) + : "Ir" (increment), "m" (*ptr) + : "memory"); + // temp2 now holds the final value. + return temp2; +} + +inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, + Atomic32 increment) { + ATOMICOPS_COMPILER_BARRIER(); + Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment); + ATOMICOPS_COMPILER_BARRIER(); + return res; +} + +// "Acquire" operations +// ensure that no later memory access can be reordered ahead of the operation. +// "Release" operations ensure that no previous memory access can be reordered +// after the operation. "Barrier" operations have both "Acquire" and "Release" +// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory +// access. +inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + ATOMICOPS_COMPILER_BARRIER(); + Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + ATOMICOPS_COMPILER_BARRIER(); + return res; +} + +inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, + Atomic32 old_value, + Atomic32 new_value) { + ATOMICOPS_COMPILER_BARRIER(); + Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value); + ATOMICOPS_COMPILER_BARRIER(); + return res; +} + +inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; +} + +inline void MemoryBarrier() { + __asm__ __volatile__("sync" : : : "memory"); +} + +inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { + *ptr = value; + MemoryBarrier(); +} + +inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { + MemoryBarrier(); + *ptr = value; +} + +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} + +inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { + Atomic32 value = *ptr; + MemoryBarrier(); + return value; +} + +inline Atomic32 Release_Load(volatile const Atomic32* ptr) { + MemoryBarrier(); + return *ptr; +} + +} // namespace base::subtle +} // namespace base + +#undef ATOMICOPS_COMPILER_BARRIER + +#endif // BASE_ATOMICOPS_INTERNALS_MIPS_GCC_H_ diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc index bf90a0f..e7560a5 100644 --- a/base/debug/debugger_posix.cc +++ b/base/debug/debugger_posix.cc @@ -169,6 +169,8 @@ bool BeingDebugged() { #define DEBUG_BREAK() abort() #elif defined(ARCH_CPU_ARM_FAMILY) #define DEBUG_BREAK() asm("bkpt 0") +#elif defined(ARCH_CPU_MIPS_FAMILY) +#define DEBUG_BREAK() asm("break 2") #else #define DEBUG_BREAK() asm("int3") #endif diff --git a/build/build_config.h b/build/build_config.h index cedac01..b17531d 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -117,6 +117,11 @@ #define ARCH_CPU_ARMEL 1 #define ARCH_CPU_32_BITS 1 #define WCHAR_T_IS_UNSIGNED 1 +#elif defined(__MIPSEL__) +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPSEL 1 +#define ARCH_CPU_32_BITS 1 +#define WCHAR_T_IS_UNSIGNED 0 #else #error Please add support for your architecture in build/build_config.h #endif diff --git a/net/http/http_auth_handler_ntlm_portable.cc b/net/http/http_auth_handler_ntlm_portable.cc index fac37c8..5fa078d 100644 --- a/net/http/http_auth_handler_ntlm_portable.cc +++ b/net/http/http_auth_handler_ntlm_portable.cc @@ -70,9 +70,13 @@ namespace net { * ***** END LICENSE BLOCK ***** */ // Discover the endianness by testing processor architecture. -#if defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_ARMEL) +#if defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64)\ + || defined(ARCH_CPU_ARMEL) || defined(ARCH_CPU_MIPSEL) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN +#elif defined(ARCH_CPU_MIPSEB) +#undef IS_LITTLE_ENDIAN +#define IS_BIG_ENDIAN 1 #else #error "Unknown endianness" #endif -- cgit v1.1 From 5dd41b50fc7d24c103522171ec2b3b89b7c0d37f Mon Sep 17 00:00:00 2001 From: Paul Lind Date: Tue, 7 Aug 2012 22:27:52 -0700 Subject: Fix lazy-instance template to preserve object alignment on MIPS. The alignment attribute of an object was discarded when allocating storage for the lazy-instance. Alignment is important for MIPS, where doubles (and objects containing them) must be aligned on 8-byte boundary. The alignment attributes are included via a macro that is only defined under GCC, so that this change does not affect other build enviromments. Change-Id: I99047cf610618de2e7e29e5de85835dc45d99231 Signed-off-by: Paul Lind --- base/lazy_instance.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/base/lazy_instance.h b/base/lazy_instance.h index 7b1bdc4..a8ff0e8 100644 --- a/base/lazy_instance.h +++ b/base/lazy_instance.h @@ -108,6 +108,14 @@ class BASE_API LazyInstanceHelper { DISALLOW_COPY_AND_ASSIGN(LazyInstanceHelper); }; +// Allow preservation of object alignment in the lazy instance when using GCC. +// __alignof__ is only defined for GCC > 4.2. +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) +#define LAZY_ALIGN(T) __attribute__((aligned(__alignof__(T)))) +#else +#define LAZY_ALIGN(T) +#endif + template > class LazyInstance : public LazyInstanceHelper { public: @@ -167,12 +175,15 @@ class LazyInstance : public LazyInstanceHelper { base::subtle::Release_Store(&me->state_, STATE_EMPTY); } - int8 buf_[sizeof(Type)]; // Preallocate the space for the Type instance. + // Preallocate the space for the Type instance, and preserve alignment. + int8 buf_[sizeof(Type)] LAZY_ALIGN(Type); Type *instance_; DISALLOW_COPY_AND_ASSIGN(LazyInstance); }; +#undef LAZY_ALIGN + } // namespace base #endif // BASE_LAZY_INSTANCE_H_ -- cgit v1.1 From c2cbc7df84951541b29200c3a6ade3163fb815ae Mon Sep 17 00:00:00 2001 From: Fengwei Yin Date: Thu, 24 May 2012 16:47:48 +0800 Subject: back port upstream patch This patch is from Chromium project. It's used to handle potential issue in scoped_refptr. This is upstream patch porting and the original link is: http://codereview.chromium.org/9021020/ unittest change was not included. Change-Id: I14ce3df0653ff29713f38eceaf07e9b409cfaedc Author: Fengwei Yin Singed-off-by: Shuo Gao Signed-off-by: Bruce Beare Signed-off-by: Jack Ren Author-tracking-BZ: 37500 --- base/memory/ref_counted.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h index 1207ed4..e35264b 100644 --- a/base/memory/ref_counted.h +++ b/base/memory/ref_counted.h @@ -260,9 +260,10 @@ class scoped_refptr { // AddRef first so that self assignment should work if (p) p->AddRef(); - if (ptr_ ) - ptr_ ->Release(); + T* old_ptr = ptr_; ptr_ = p; + if (old_ptr) + old_ptr ->Release(); return *this; } -- cgit v1.1 From de6c9f9aec5e2e7e66cb77140f7418fc29644ef0 Mon Sep 17 00:00:00 2001 From: Selim Gurun Date: Thu, 30 Aug 2012 12:40:10 -0700 Subject: Disable compression. Bug: 7079965 Change-Id: I6d5ac7d90fc2298b5e8a92cfae1ffb840016b88b --- net/socket/ssl_client_socket_openssl.cc | 4 ++++ net/spdy/spdy_framer.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc index 30a5f48..5668c8a 100644 --- a/net/socket/ssl_client_socket_openssl.cc +++ b/net/socket/ssl_client_socket_openssl.cc @@ -457,8 +457,12 @@ bool SSLClientSocketOpenSSL::Init() { #if defined(SSL_OP_NO_COMPRESSION) // If TLS was disabled also disable compression, to provide maximum site // compatibility in the case of protocol fallback. See http://crbug.com/31628 +#ifdef ANDROID + options.ConfigureFlag(SSL_OP_NO_COMPRESSION, true); +#else options.ConfigureFlag(SSL_OP_NO_COMPRESSION, !ssl_config_.tls1_enabled); #endif +#endif // TODO(joth): Set this conditionally, see http://crbug.com/55410 options.ConfigureFlag(SSL_OP_LEGACY_SERVER_CONNECT, true); diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index 878b199..5f645fc 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -27,7 +27,11 @@ namespace { // The following compression setting are based on Brian Olson's analysis. See // https://groups.google.com/group/spdy-dev/browse_thread/thread/dfaf498542fac792 // for more details. +#ifdef ANDROID +const int kCompressorLevel = 0; +#else const int kCompressorLevel = 9; +#endif const int kCompressorWindowSizeInBits = 11; const int kCompressorMemLevel = 1; -- cgit v1.1 From a7f1721675b8b6e0389732f1e25788012f7c20b7 Mon Sep 17 00:00:00 2001 From: Magnus Hallqvist Date: Tue, 17 Jan 2012 09:58:24 +0100 Subject: Null pointer check missing in chromium When clearing a struct a null pointer check is missing in one location in chromium. The null check is present in another similar use cases. When the backend cache is reset a member of the struct data_ is set to zero before data_ itself is set to null. If the backend cache previously has been reset data_ will already be null and the member cannot be accessed (or uses undefined memory). The added null check will prevent the clearing of the member variable when data_ is already null. Change-Id: I475fea7436c871c2e82b841a93874e13a05161f4 --- net/disk_cache/backend_impl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 117f20b..81c44d5 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -1484,7 +1484,13 @@ void BackendImpl::PrepareForRestart() { new_eviction_ = false; disabled_ = true; - data_->header.crash = 0; +#ifdef ANDROID + if (data_) { +#endif + data_->header.crash = 0; +#ifdef ANDROID + } +#endif index_ = NULL; data_ = NULL; block_files_.CloseFiles(); -- cgit v1.1