0

Fix ASAN ODR violation in ppapi/proxy in component mode

See https://groups.google.com/a/chromium.org/d/topic/chromium-dev/12dRlYvL9nI/discussion.

Confirmed with

gn gen out/asan --args="is_asan=true enable_nacl=false is_debug=false use_goma=true is_component_build=true"

BUG=581766

Review-Url: https://codereview.chromium.org/2727093003
Cr-Commit-Position: refs/heads/master@{#454533}
This commit is contained in:
scottmg
2017-03-02 22:53:42 -08:00
committed by Commit bot
parent 9bb7606ad2
commit 5178c39691
7 changed files with 19 additions and 62 deletions

@ -308,13 +308,9 @@ component("proxy") {
source_set("common") {
sources = [
"tcp_socket_resource_constants.cc",
"tcp_socket_resource_constants.h",
"udp_socket_resource_constants.cc",
"udp_socket_resource_constants.h",
]
configs += [ ":proxy_implementation" ]
}
group("ipc") {

@ -207,7 +207,8 @@ int32_t TCPSocketResourceBase::ReadImpl(
return PP_ERROR_INPROGRESS;
read_buffer_ = buffer;
bytes_to_read_ =
std::min(bytes_to_read, TCPSocketResourceConstants::kMaxReadSize);
std::min(bytes_to_read,
static_cast<int32_t>(TCPSocketResourceConstants::kMaxReadSize));
read_callback_ = callback;
Call<PpapiPluginMsg_TCPSocket_ReadReply>(

@ -1,18 +0,0 @@
// Copyright 2017 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.
#include "ppapi/proxy/tcp_socket_resource_constants.h"
namespace ppapi {
namespace proxy {
const int32_t TCPSocketResourceConstants::kMaxReadSize = 1024 * 1024;
const int32_t TCPSocketResourceConstants::kMaxWriteSize = 1024 * 1024;
const int32_t TCPSocketResourceConstants::kMaxSendBufferSize =
1024 * TCPSocketResourceConstants::kMaxWriteSize;
const int32_t TCPSocketResourceConstants::kMaxReceiveBufferSize =
1024 * TCPSocketResourceConstants::kMaxReadSize;
} // namespace proxy
} // namespace ppapi

@ -5,30 +5,29 @@
#include <stdint.h>
#include "base/macros.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
namespace ppapi {
namespace proxy {
class PPAPI_PROXY_EXPORT TCPSocketResourceConstants {
class TCPSocketResourceConstants {
public:
// The maximum number of bytes that each PpapiHostMsg_PPBTCPSocket_Read
// message is allowed to request.
static const int32_t kMaxReadSize;
enum { kMaxReadSize = 1024 * 1024 };
// The maximum number of bytes that each PpapiHostMsg_PPBTCPSocket_Write
// message is allowed to carry.
static const int32_t kMaxWriteSize;
enum { kMaxWriteSize = 1024 * 1024 };
// The maximum number that we allow for setting
// PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE. This number is only for input
// argument sanity check, it doesn't mean the browser guarantees to support
// such a buffer size.
static const int32_t kMaxSendBufferSize;
enum { kMaxSendBufferSize = 1024 * kMaxWriteSize };
// The maximum number that we allow for setting
// PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE. This number is only for input
// argument sanity check, it doesn't mean the browser guarantees to support
// such a buffer size.
static const int32_t kMaxReceiveBufferSize;
enum { kMaxReceiveBufferSize = 1024 * kMaxReadSize };
private:
DISALLOW_COPY_AND_ASSIGN(TCPSocketResourceConstants);

@ -153,7 +153,8 @@ void UDPSocketFilter::RecvQueue::DataReceivedOnIOThread(
const PP_NetAddress_Private& addr) {
DCHECK(PluginGlobals::Get()->ipc_task_runner()->RunsTasksOnCurrentThread());
DCHECK_LT(recv_buffers_.size(),
UDPSocketResourceConstants::kPluginReceiveBufferSlots);
static_cast<size_t>(
UDPSocketResourceConstants::kPluginReceiveBufferSlots));
if (!TrackedCallback::IsPending(recvfrom_callback_) || !read_buffer_) {
recv_buffers_.push(RecvBuffer());
@ -213,8 +214,9 @@ int32_t UDPSocketFilter::RecvQueue::RequestData(
if (recv_buffers_.empty()) {
read_buffer_ = buffer_out;
bytes_to_read_ =
std::min(num_bytes, UDPSocketResourceConstants::kMaxReadSize);
bytes_to_read_ = std::min(
num_bytes,
static_cast<int32_t>(UDPSocketResourceConstants::kMaxReadSize));
recvfrom_addr_resource_ = addr_out;
recvfrom_callback_ = callback;
return PP_OK_COMPLETIONPENDING;

@ -1,22 +0,0 @@
// Copyright 2017 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.
#include "ppapi/proxy/udp_socket_resource_constants.h"
namespace ppapi {
namespace proxy {
const int32_t UDPSocketResourceConstants::kMaxWriteSize = 128 * 1024;
const int32_t UDPSocketResourceConstants::kMaxReadSize = 128 * 1024;
const int32_t UDPSocketResourceConstants::kMaxSendBufferSize =
1024 * UDPSocketResourceConstants::kMaxWriteSize;
const int32_t UDPSocketResourceConstants::kMaxReceiveBufferSize =
1024 * UDPSocketResourceConstants::kMaxReadSize;
const size_t UDPSocketResourceConstants::kPluginSendBufferSlots = 8u;
const size_t UDPSocketResourceConstants::kPluginReceiveBufferSlots = 32u;
} // namespace proxy
} // namespace ppapi

@ -5,37 +5,36 @@
#include <stdint.h>
#include "base/macros.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
namespace ppapi {
namespace proxy {
class PPAPI_PROXY_EXPORT UDPSocketResourceConstants {
class UDPSocketResourceConstants {
public:
// The maximum number of bytes that each
// PpapiPluginMsg_PPBUDPSocket_PushRecvResult message is allowed to carry.
static const int32_t kMaxReadSize;
enum { kMaxReadSize = 128 * 1024 };
// The maximum number of bytes that each PpapiHostMsg_PPBUDPSocket_SendTo
// message is allowed to carry.
static const int32_t kMaxWriteSize;
enum { kMaxWriteSize = 128 * 1024 };
// The maximum number that we allow for setting
// PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE. This number is only for input
// argument sanity check, it doesn't mean the browser guarantees to support
// such a buffer size.
static const int32_t kMaxSendBufferSize;
enum { kMaxSendBufferSize = 1024 * kMaxWriteSize };
// The maximum number that we allow for setting
// PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE. This number is only for input
// argument sanity check, it doesn't mean the browser guarantees to support
// such a buffer size.
static const int32_t kMaxReceiveBufferSize;
enum { kMaxReceiveBufferSize = 1024 * kMaxReadSize };
// The maximum number of received packets that we allow instances of this
// class to buffer.
static const size_t kPluginReceiveBufferSlots;
enum { kPluginReceiveBufferSlots = 32u };
// The maximum number of buffers that we allow instances of this class to be
// sending before we block the plugin.
static const size_t kPluginSendBufferSlots;
enum { kPluginSendBufferSlots = 8u };
private:
DISALLOW_COPY_AND_ASSIGN(UDPSocketResourceConstants);