Commit e9478a99 authored by shenhan@google.com's avatar shenhan@google.com

Fix gcc 4.7 building problems - cont 2.

(The gcc 4.7 building problems keep popping up as I sync the repo, so there are several "fix gcc 4.7 .." cls.)

Fixes include -
- added static_cast for narrowing conversion in simple(short)
  initiliazation lists
- added explicit <unistd.h> inclusion

BUG=None
TEST=Built successfully using GCC-4.7 under linux and under chromeos chroot.


Review URL: https://chromiumcodereview.appspot.com/10833017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148519 0039d316-1c4b-4281-b951-d872f2087c98
parent c6e5ca6d
......@@ -16,21 +16,23 @@ namespace {
// Check if particular nameserver address is rogue. See:
// http://www.fbi.gov/news/stories/2011/november/malware_110911/DNS-changer-malware.pdf
bool CheckRogueDnsAddress(const IPAddressNumber& address) {
#define U8(x) static_cast<unsigned char>(x)
const struct Bounds {
const unsigned char lower[4]; // inclusive
const unsigned char upper[4]; // exclusive
} cases[] = {
{ { '\x55', '\xFF', '\x70', '\x00' }, // 85.255.112.0
{ '\x55', '\xFF', '\x80', '\x00' } }, // 85.255.128.0
{ { '\x43', '\xD2', '\x00', '\x00' }, // 67.210.0.0
{ '\x43', '\xD2', '\x10', '\x00' } }, // 67.210.16.0
{ { '\x5D', '\xBC', '\xA0', '\x00' }, // 93.188.160.0
{ '\x5D', '\xBC', '\xA8', '\x00' } }, // 93.188.168.0
{ { '\x4D', '\x43', '\x53', '\x00' }, // 77.67.83.0
{ '\x4D', '\x43', '\x54', '\x00' } }, // 77.67.84.0
{ { '\x40', '\x1C', '\xB2', '\x00' }, // 64.28.178.0
{ '\x40', '\x1C', '\xC0', '\x00' } }, // 64.28.192.0
{ { U8('\x55'), U8('\xFF'), U8('\x70'), U8('\x00') }, // 85.255.112.0
{ U8('\x55'), U8('\xFF'), U8('\x80'), U8('\x00') } }, // 85.255.128.0
{ { U8('\x43'), U8('\xD2'), U8('\x00'), U8('\x00') }, // 67.210.0.0
{ U8('\x43'), U8('\xD2'), U8('\x10'), U8('\x00') } }, // 67.210.16.0
{ { U8('\x5D'), U8('\xBC'), U8('\xA0'), U8('\x00') }, // 93.188.160.0
{ U8('\x5D'), U8('\xBC'), U8('\xA8'), U8('\x00') } }, // 93.188.168.0
{ { U8('\x4D'), U8('\x43'), U8('\x53'), U8('\x00') }, // 77.67.83.0
{ U8('\x4D'), U8('\x43'), U8('\x54'), U8('\x00') } }, // 77.67.84.0
{ { U8('\x40'), U8('\x1C'), U8('\xB2'), U8('\x00') }, // 64.28.178.0
{ U8('\x40'), U8('\x1C'), U8('\xC0'), U8('\x00') } }, // 64.28.192.0
};
#undef U8
for (unsigned i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
const Bounds& bounds = cases[i];
IPAddressNumber lower(bounds.lower, bounds.lower + 4);
......
......@@ -8,6 +8,7 @@
#include <pthread.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include "base/eintr_wrapper.h"
#include "base/logging.h"
......
......@@ -4,6 +4,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "base/eintr_wrapper.h"
#include "base/environment.h"
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -38,8 +38,14 @@ int32 ExecuteStreamJavaScript::Write(NPStream *stream, int32 offset, int32 len,
std::string javascript("javascript:");
javascript.append(static_cast<char*>(buffer), len);
size_t js_length = javascript.length();
if (js_length != static_cast<uint32_t>(js_length)) {
SetError("Javascript too long.");
return -1;
}
NPString script_string = { javascript.c_str(), javascript.length() };
NPString script_string = { javascript.c_str(),
static_cast<uint32_t>(js_length) };
NPObject *window_obj = NULL;
NPAPIClient::PluginClient::HostFunctions()->getvalue(
id(), NPNVWindowNPObject, &window_obj);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -134,7 +134,13 @@ NPError WindowlessPluginTest::ExecuteScript(NPNetscapeFuncs* browser, NPP id,
std::string script_url = "javascript:";
script_url += script;
NPString script_string = { script_url.c_str(), script_url.length() };
size_t script_length = script_url.length();
if (script_length != static_cast<uint32_t>(script_length)) {
return NPERR_GENERIC_ERROR;
}
NPString script_string = { script_url.c_str(),
static_cast<uint32_t>(script_length) };
NPObject *window_obj = NULL;
browser->getvalue(id, NPNVWindowNPObject, &window_obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment