project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
Chrome
|
b2dfe7c175fb21263f06eb586f1ed235482a3281
| 1 |
static void _ewk_frame_smart_del(Evas_Object* ewkFrame)
{
EWK_FRAME_SD_GET(ewkFrame, smartData);
if (smartData) {
if (smartData->frame) {
WebCore::FrameLoaderClientEfl* flc = _ewk_frame_loader_efl_get(smartData->frame);
flc->setWebFrame(0);
smartData->frame->loader()->detachFromParent();
smartData->frame->loader()->cancelAndClear();
smartData->frame = 0;
}
eina_stringshare_del(smartData->title);
eina_stringshare_del(smartData->uri);
eina_stringshare_del(smartData->name);
}
_parent_sc.del(ewkFrame);
}
|
CWE-399
| 184,670 | 5,603 |
248859574807383014889182456283152158628
| null | null | null |
Chrome
|
d6cc2749d2f90acc2d92a526c1d2cbebbc101a19
| 1 |
void SyncManager::SyncInternal::OnIPAddressChanged() {
DVLOG(1) << "IP address change detected";
if (!observing_ip_address_changes_) {
DVLOG(1) << "IP address change dropped.";
return;
}
#if defined (OS_CHROMEOS)
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&SyncInternal::OnIPAddressChangedImpl,
weak_ptr_factory_.GetWeakPtr()),
kChromeOSNetworkChangeReactionDelayHackMsec);
#else
OnIPAddressChangedImpl();
#endif // defined(OS_CHROMEOS)
}
|
CWE-399
| 184,679 | 5,612 |
213258874955973970755962665697577880617
| null | null | null |
Chrome
|
f3030ed0e4a5832b62dc0d434c08be21203fd17b
| 1 |
AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
const ScoredHistoryMatch& history_match,
int score) {
const history::URLRow& info = history_match.url_info;
AutocompleteMatch match(this, score, !!info.visit_count(),
history_match.url_matches.empty() ?
AutocompleteMatch::HISTORY_URL : AutocompleteMatch::HISTORY_TITLE);
match.destination_url = info.url();
DCHECK(match.destination_url.is_valid());
std::vector<size_t> offsets =
OffsetsFromTermMatches(history_match.url_matches);
const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll &
~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP);
match.fill_into_edit =
AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(),
net::FormatUrlWithOffsets(info.url(), languages_, format_types,
net::UnescapeRule::SPACES, NULL, NULL, &offsets));
history::TermMatches new_matches =
ReplaceOffsetsInTermMatches(history_match.url_matches, offsets);
match.contents = net::FormatUrl(info.url(), languages_, format_types,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
match.contents_class =
SpansFromTermMatch(new_matches, match.contents.length(), true);
if (!history_match.can_inline) {
match.inline_autocomplete_offset = string16::npos;
} else {
DCHECK(!new_matches.empty());
match.inline_autocomplete_offset = new_matches[0].offset +
new_matches[0].length;
if (match.inline_autocomplete_offset > match.fill_into_edit.length())
match.inline_autocomplete_offset = match.fill_into_edit.length();
}
match.description = info.title();
match.description_class = SpansFromTermMatch(
history_match.title_matches, match.description.length(), false);
return match;
}
| 184,691 | 5,624 |
178871423508701762432946164337817683469
| null | null | null |
|
Chrome
|
7ee3acb08d9de663e5ec3148ee98b666cd32ad82
| 1 |
int BrowserNonClientFrameViewAura::NonClientTopBorderHeight(
bool force_restored) const {
if (frame()->widget_delegate() &&
frame()->widget_delegate()->ShouldShowWindowTitle()) {
return close_button_->bounds().bottom();
}
if (!frame()->IsMaximized() || force_restored)
return kTabstripTopSpacingRestored;
return kTabstripTopSpacingMaximized;
}
|
CWE-119
| 184,696 | 5,629 |
211513149709653660114436122650114461642
| null | null | null |
Chrome
|
d6b061bf189e0661a3d94d89dbcb2e6f70b433da
| 1 |
void ProfileImplIOData::LazyInitializeInternal(
ProfileParams* profile_params) const {
clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit;
ChromeURLRequestContext* main_context = main_request_context();
ChromeURLRequestContext* extensions_context = extensions_request_context();
media_request_context_ = new ChromeURLRequestContext;
IOThread* const io_thread = profile_params->io_thread;
IOThread::Globals* const io_thread_globals = io_thread->globals();
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
bool record_mode = chrome::kRecordModeEnabled &&
command_line.HasSwitch(switches::kRecordMode);
bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode);
ApplyProfileParamsToContext(main_context);
ApplyProfileParamsToContext(media_request_context_);
ApplyProfileParamsToContext(extensions_context);
if (http_server_properties_manager_.get())
http_server_properties_manager_->InitializeOnIOThread();
main_context->set_transport_security_state(transport_security_state());
media_request_context_->set_transport_security_state(
transport_security_state());
extensions_context->set_transport_security_state(transport_security_state());
main_context->set_net_log(io_thread->net_log());
media_request_context_->set_net_log(io_thread->net_log());
extensions_context->set_net_log(io_thread->net_log());
main_context->set_network_delegate(network_delegate());
media_request_context_->set_network_delegate(network_delegate());
main_context->set_http_server_properties(http_server_properties());
media_request_context_->set_http_server_properties(http_server_properties());
main_context->set_host_resolver(
io_thread_globals->host_resolver.get());
media_request_context_->set_host_resolver(
io_thread_globals->host_resolver.get());
main_context->set_cert_verifier(
io_thread_globals->cert_verifier.get());
media_request_context_->set_cert_verifier(
io_thread_globals->cert_verifier.get());
main_context->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
media_request_context_->set_http_auth_handler_factory(
io_thread_globals->http_auth_handler_factory.get());
main_context->set_fraudulent_certificate_reporter(
fraudulent_certificate_reporter());
media_request_context_->set_fraudulent_certificate_reporter(
fraudulent_certificate_reporter());
main_context->set_proxy_service(proxy_service());
media_request_context_->set_proxy_service(proxy_service());
scoped_refptr<net::CookieStore> cookie_store = NULL;
net::OriginBoundCertService* origin_bound_cert_service = NULL;
if (record_mode || playback_mode) {
cookie_store = new net::CookieMonster(
NULL, profile_params->cookie_monster_delegate);
origin_bound_cert_service = new net::OriginBoundCertService(
new net::DefaultOriginBoundCertStore(NULL));
}
if (!cookie_store) {
DCHECK(!lazy_params_->cookie_path.empty());
scoped_refptr<SQLitePersistentCookieStore> cookie_db =
new SQLitePersistentCookieStore(
lazy_params_->cookie_path,
lazy_params_->restore_old_session_cookies);
cookie_db->SetClearLocalStateOnExit(
profile_params->clear_local_state_on_exit);
cookie_store =
new net::CookieMonster(cookie_db.get(),
profile_params->cookie_monster_delegate);
if (command_line.HasSwitch(switches::kEnableRestoreSessionState))
cookie_store->GetCookieMonster()->SetPersistSessionCookies(true);
}
net::CookieMonster* extensions_cookie_store =
new net::CookieMonster(
new SQLitePersistentCookieStore(
lazy_params_->extensions_cookie_path,
lazy_params_->restore_old_session_cookies), NULL);
const char* schemes[] = {chrome::kChromeDevToolsScheme,
chrome::kExtensionScheme};
extensions_cookie_store->SetCookieableSchemes(schemes, 2);
main_context->set_cookie_store(cookie_store);
media_request_context_->set_cookie_store(cookie_store);
extensions_context->set_cookie_store(extensions_cookie_store);
if (!origin_bound_cert_service) {
DCHECK(!lazy_params_->origin_bound_cert_path.empty());
scoped_refptr<SQLiteOriginBoundCertStore> origin_bound_cert_db =
new SQLiteOriginBoundCertStore(lazy_params_->origin_bound_cert_path);
origin_bound_cert_db->SetClearLocalStateOnExit(
profile_params->clear_local_state_on_exit);
origin_bound_cert_service = new net::OriginBoundCertService(
new net::DefaultOriginBoundCertStore(origin_bound_cert_db.get()));
}
set_origin_bound_cert_service(origin_bound_cert_service);
main_context->set_origin_bound_cert_service(origin_bound_cert_service);
media_request_context_->set_origin_bound_cert_service(
origin_bound_cert_service);
net::HttpCache::DefaultBackend* main_backend =
new net::HttpCache::DefaultBackend(
net::DISK_CACHE,
lazy_params_->cache_path,
lazy_params_->cache_max_size,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
net::HttpCache* main_cache = new net::HttpCache(
main_context->host_resolver(),
main_context->cert_verifier(),
main_context->origin_bound_cert_service(),
main_context->transport_security_state(),
main_context->proxy_service(),
"", // pass empty ssl_session_cache_shard to share the SSL session cache
main_context->ssl_config_service(),
main_context->http_auth_handler_factory(),
main_context->network_delegate(),
main_context->http_server_properties(),
main_context->net_log(),
main_backend);
net::HttpCache::DefaultBackend* media_backend =
new net::HttpCache::DefaultBackend(
net::MEDIA_CACHE, lazy_params_->media_cache_path,
lazy_params_->media_cache_max_size,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
net::HttpNetworkSession* main_network_session = main_cache->GetSession();
net::HttpCache* media_cache =
new net::HttpCache(main_network_session, media_backend);
if (record_mode || playback_mode) {
main_cache->set_mode(
record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
}
main_http_factory_.reset(main_cache);
media_http_factory_.reset(media_cache);
main_context->set_http_transaction_factory(main_cache);
media_request_context_->set_http_transaction_factory(media_cache);
ftp_factory_.reset(
new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
main_context->set_ftp_transaction_factory(ftp_factory_.get());
main_context->set_chrome_url_data_manager_backend(
chrome_url_data_manager_backend());
main_context->set_job_factory(job_factory());
media_request_context_->set_job_factory(job_factory());
extensions_context->set_job_factory(job_factory());
job_factory()->AddInterceptor(
new chrome_browser_net::ConnectInterceptor(predictor_.get()));
lazy_params_.reset();
}
|
CWE-119
| 184,697 | 5,630 |
275693883405654987674055104513308759992
| null | null | null |
Chrome
|
8f0b86c2fc77fca1508d81314f864011abe25f04
| 1 |
bool GLES2DecoderImpl::SimulateAttrib0(
GLuint max_vertex_accessed, bool* simulated) {
DCHECK(simulated);
*simulated = false;
if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
return true;
const VertexAttribManager::VertexAttribInfo* info =
vertex_attrib_manager_->GetVertexAttribInfo(0);
bool attrib_0_used = current_program_->GetAttribInfoByLocation(0) != NULL;
if (info->enabled() && attrib_0_used) {
return true;
}
typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4;
GLuint num_vertices = max_vertex_accessed + 1;
GLuint size_needed = 0;
if (num_vertices == 0 ||
!SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)),
&size_needed) ||
size_needed > 0x7FFFFFFFU) {
SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0");
return false;
}
CopyRealGLErrorsToWrapper();
glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
if (static_cast<GLsizei>(size_needed) > attrib_0_size_) {
glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW);
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
SetGLError(GL_OUT_OF_MEMORY, "glDrawXXX: Simulating attrib 0");
return false;
}
attrib_0_buffer_matches_value_ = false;
}
if (attrib_0_used &&
(!attrib_0_buffer_matches_value_ ||
(info->value().v[0] != attrib_0_value_.v[0] ||
info->value().v[1] != attrib_0_value_.v[1] ||
info->value().v[2] != attrib_0_value_.v[2] ||
info->value().v[3] != attrib_0_value_.v[3]))) {
std::vector<Vec4> temp(num_vertices, info->value());
glBufferSubData(GL_ARRAY_BUFFER, 0, size_needed, &temp[0].v[0]);
attrib_0_buffer_matches_value_ = true;
attrib_0_value_ = info->value();
attrib_0_size_ = size_needed;
}
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL);
if (info->divisor())
glVertexAttribDivisorANGLE(0, 0);
*simulated = true;
return true;
}
| 184,750 | 5,679 |
147183265097561512161736529181187592784
| null | null | null |
|
Chrome
|
3da579b85a36e95c03d06b7c4ce9d618af4107bf
| 1 |
BookmarkManagerView::BookmarkManagerView(Profile* profile)
: profile_(profile->GetOriginalProfile()),
table_view_(NULL),
tree_view_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(search_factory_(this)) {
search_tf_ = new views::TextField();
search_tf_->set_default_width_in_chars(30);
table_view_ = new BookmarkTableView(profile_, NULL);
table_view_->SetObserver(this);
table_view_->SetContextMenuController(this);
tree_view_ = new BookmarkFolderTreeView(profile_, NULL);
tree_view_->SetController(this);
tree_view_->SetContextMenuController(this);
views::MenuButton* organize_menu_button = new views::MenuButton(
NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU),
this, true);
organize_menu_button->SetID(kOrganizeMenuButtonID);
views::MenuButton* tools_menu_button = new views::MenuButton(
NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_TOOLS_MENU),
this, true);
tools_menu_button->SetID(kToolsMenuButtonID);
split_view_ = new views::SingleSplitView(tree_view_, table_view_);
split_view_->set_background(
views::Background::CreateSolidBackground(kBackgroundColorBottom));
views::GridLayout* layout = new views::GridLayout(this);
SetLayoutManager(layout);
const int top_id = 1;
const int split_cs_id = 2;
layout->SetInsets(2, 0, 0, 0); // 2px padding above content.
views::ColumnSet* column_set = layout->AddColumnSet(top_id);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(1, kUnrelatedControlHorizontalSpacing);
column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
0, views::GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, 3); // 3px padding at end of row.
column_set = layout->AddColumnSet(split_cs_id);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, top_id);
layout->AddView(organize_menu_button);
layout->AddView(tools_menu_button);
layout->AddView(new views::Label(
l10n_util::GetString(IDS_BOOKMARK_MANAGER_SEARCH_TITLE)));
layout->AddView(search_tf_);
layout->AddPaddingRow(0, 3); // 3px padding between rows.
layout->StartRow(1, split_cs_id);
layout->AddView(split_view_);
BookmarkModel* bookmark_model = profile_->GetBookmarkModel();
if (!bookmark_model->IsLoaded())
bookmark_model->AddObserver(this);
}
|
CWE-399
| 184,752 | 5,680 |
206164856550084267165179419367204495641
| null | null | null |
Chrome
|
4cf106cdb83dd6b35d3b26d06cc67d1d2d99041e
| 1 |
png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
png_bytep output, png_size_t output_size)
{
png_size_t count = 0;
png_ptr->zstream.next_in = (png_bytep)data; /* const_cast: VALID */
png_ptr->zstream.avail_in = size;
while (1)
{
int ret, avail;
/* Reset the output buffer each time round - we empty it
* after every inflate call.
*/
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);
avail = png_ptr->zbuf_size - png_ptr->zstream.avail_out;
/* First copy/count any new output - but only if we didn't
* get an error code.
*/
if ((ret == Z_OK || ret == Z_STREAM_END) && avail > 0)
{
if (output != 0 && output_size > count)
{
int copy = output_size - count;
if (avail < copy) copy = avail;
png_memcpy(output + count, png_ptr->zbuf, copy);
}
count += avail;
}
if (ret == Z_OK)
continue;
/* Termination conditions - always reset the zstream, it
* must be left in inflateInit state.
*/
png_ptr->zstream.avail_in = 0;
inflateReset(&png_ptr->zstream);
if (ret == Z_STREAM_END)
return count; /* NOTE: may be zero. */
/* Now handle the error codes - the API always returns 0
* and the error message is dumped into the uncompressed
* buffer if available.
*/
{
PNG_CONST char *msg;
if (png_ptr->zstream.msg != 0)
msg = png_ptr->zstream.msg;
else
{
#if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE)
char umsg[52];
switch (ret)
{
case Z_BUF_ERROR:
msg = "Buffer error in compressed datastream in %s chunk";
break;
case Z_DATA_ERROR:
msg = "Data error in compressed datastream in %s chunk";
break;
default:
msg = "Incomplete compressed datastream in %s chunk";
break;
}
png_snprintf(umsg, sizeof umsg, msg, png_ptr->chunk_name);
msg = umsg;
#else
msg = "Damaged compressed datastream in chunk other than IDAT";
#endif
}
png_warning(png_ptr, msg);
}
/* 0 means an error - notice that this code simple ignores
* zero length compressed chunks as a result.
*/
return 0;
}
}
|
CWE-189
| 184,753 | 5,681 |
186299551334314546195681877845857691086
| null | null | null |
Chrome
|
d66c757a9a434f48069b114fb49191e4790f9038
| 1 |
void InputMethodBase::OnInputMethodChanged() const {
TextInputClient* client = GetTextInputClient();
if (client && client->GetTextInputType() != TEXT_INPUT_TYPE_NONE)
client->OnInputMethodChanged();
}
|
CWE-399
| 184,754 | 5,682 |
39701825873439796626730255657605199309
| null | null | null |
Chrome
|
50370b3c98047bdc80184ff87a502edc5c597d3a
| 1 |
void OneClickSigninHelper::ShowInfoBarIfPossible(net::URLRequest* request,
ProfileIOData* io_data,
int child_id,
int route_id) {
std::string google_chrome_signin_value;
std::string google_accounts_signin_value;
request->GetResponseHeaderByName("Google-Chrome-SignIn",
&google_chrome_signin_value);
request->GetResponseHeaderByName("Google-Accounts-SignIn",
&google_accounts_signin_value);
if (!google_accounts_signin_value.empty() ||
!google_chrome_signin_value.empty()) {
VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:"
<< " g-a-s='" << google_accounts_signin_value << "'"
<< " g-c-s='" << google_chrome_signin_value << "'";
}
if (!gaia::IsGaiaSignonRealm(request->original_url().GetOrigin()))
return;
std::vector<std::pair<std::string, std::string> > pairs;
base::SplitStringIntoKeyValuePairs(google_accounts_signin_value, '=', ',',
&pairs);
std::string session_index;
std::string email;
for (size_t i = 0; i < pairs.size(); ++i) {
const std::pair<std::string, std::string>& pair = pairs[i];
const std::string& key = pair.first;
const std::string& value = pair.second;
if (key == "email") {
TrimString(value, "\"", &email);
} else if (key == "sessionindex") {
session_index = value;
}
}
if (!email.empty())
io_data->set_reverse_autologin_pending_email(email);
if (!email.empty() || !session_index.empty()) {
VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:"
<< " email=" << email
<< " sessionindex=" << session_index;
}
AutoAccept auto_accept = AUTO_ACCEPT_NONE;
signin::Source source = signin::SOURCE_UNKNOWN;
GURL continue_url;
std::vector<std::string> tokens;
base::SplitString(google_chrome_signin_value, ',', &tokens);
for (size_t i = 0; i < tokens.size(); ++i) {
const std::string& token = tokens[i];
if (token == "accepted") {
auto_accept = AUTO_ACCEPT_ACCEPTED;
} else if (token == "configure") {
auto_accept = AUTO_ACCEPT_CONFIGURE;
} else if (token == "rejected-for-profile") {
auto_accept = AUTO_ACCEPT_REJECTED_FOR_PROFILE;
}
}
source = GetSigninSource(request->url(), &continue_url);
if (source != signin::SOURCE_UNKNOWN)
auto_accept = AUTO_ACCEPT_EXPLICIT;
if (auto_accept != AUTO_ACCEPT_NONE) {
VLOG(1) << "OneClickSigninHelper::ShowInfoBarIfPossible:"
<< " auto_accept=" << auto_accept;
}
if (session_index.empty() && email.empty() &&
auto_accept == AUTO_ACCEPT_NONE && !continue_url.is_valid()) {
return;
}
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&OneClickSigninHelper::ShowInfoBarUIThread, session_index,
email, auto_accept, source, continue_url, child_id, route_id));
}
|
CWE-287
| 184,828 | 5,746 |
329027838139599458035556302218011799301
| null | null | null |
Chrome
|
516abadc2553489ce28faeea4917280032fbe91d
| 1 |
bool AffiliationFetcher::ParseResponse(
AffiliationFetcherDelegate::Result* result) const {
std::string serialized_response;
if (!fetcher_->GetResponseAsString(&serialized_response)) {
NOTREACHED();
}
affiliation_pb::LookupAffiliationResponse response;
if (!response.ParseFromString(serialized_response))
return false;
result->reserve(requested_facet_uris_.size());
std::map<FacetURI, size_t> facet_uri_to_class_index;
for (int i = 0; i < response.affiliation_size(); ++i) {
const affiliation_pb::Affiliation& equivalence_class(
response.affiliation(i));
AffiliatedFacets affiliated_uris;
for (int j = 0; j < equivalence_class.facet_size(); ++j) {
const std::string& uri_spec(equivalence_class.facet(j));
FacetURI uri = FacetURI::FromPotentiallyInvalidSpec(uri_spec);
if (!uri.is_valid())
continue;
affiliated_uris.push_back(uri);
}
if (affiliated_uris.empty())
continue;
for (const FacetURI& uri : affiliated_uris) {
if (!facet_uri_to_class_index.count(uri))
facet_uri_to_class_index[uri] = result->size();
if (facet_uri_to_class_index[uri] !=
facet_uri_to_class_index[affiliated_uris[0]]) {
return false;
}
}
if (facet_uri_to_class_index[affiliated_uris[0]] == result->size())
result->push_back(affiliated_uris);
}
for (const FacetURI& uri : requested_facet_uris_) {
if (!facet_uri_to_class_index.count(uri))
result->push_back(AffiliatedFacets(1, uri));
}
return true;
}
|
CWE-119
| 184,835 | 5,753 |
69665751058673702840197501627887827643
| null | null | null |
Chrome
|
4039d2fcaab746b6c20017ba9bb51c3a2403a76c
| 1 |
bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
RenderFrameObserver* observer;
while ((observer = it.GetNext()) != NULL) {
if (observer->OnMessageReceived(msg))
return true;
}
bool handled = true;
bool msg_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameImpl, msg, msg_is_ok)
IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload)
IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut)
IPC_MESSAGE_HANDLER(FrameMsg_BuffersSwapped, OnBuffersSwapped)
IPC_MESSAGE_HANDLER_GENERIC(FrameMsg_CompositorFrameSwapped,
OnCompositorFrameSwapped(msg))
IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone)
IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed)
IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction,
OnCustomContextMenuAction)
IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
IPC_MESSAGE_HANDLER(InputMsg_Unselect, OnUnselect)
IPC_MESSAGE_HANDLER(InputMsg_Replace, OnReplace)
IPC_MESSAGE_HANDLER(InputMsg_ReplaceMisspelling, OnReplaceMisspelling)
IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest)
IPC_MESSAGE_HANDLER(FrameMsg_JavaScriptExecuteRequest,
OnJavaScriptExecuteRequest)
IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets,
OnSetEditableSelectionOffsets)
IPC_MESSAGE_HANDLER(FrameMsg_SetCompositionFromExistingText,
OnSetCompositionFromExistingText)
IPC_MESSAGE_HANDLER(FrameMsg_ExtendSelectionAndDelete,
OnExtendSelectionAndDelete)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
#endif
IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
IPC_END_MESSAGE_MAP_EX()
if (!msg_is_ok) {
CHECK(false) << "Unable to deserialize message in RenderFrameImpl.";
}
return handled;
}
|
CWE-399
| 184,836 | 5,754 |
65084460350670608925541239504296857347
| null | null | null |
Chrome
|
90fb08ed0146c9beacfd4dde98a20fc45419fff3
| 1 |
void WebContentsImpl::AttachInterstitialPage(
InterstitialPageImpl* interstitial_page) {
DCHECK(interstitial_page);
render_manager_.set_interstitial_page(interstitial_page);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidAttachInterstitialPage());
}
| 184,852 | 5,768 |
313307142426330003427523737440768325
| null | null | null |
|
Chrome
|
d6805d0d1d21976cf16d0237d9091f7eebea4ea5
| 1 |
void EnsureInitializeForAndroidLayoutTests() {
CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree));
JNIEnv* env = base::android::AttachCurrentThread();
content::NestedMessagePumpAndroid::RegisterJni(env);
content::RegisterNativesImpl(env);
bool success = base::MessageLoop::InitMessagePumpForUIFactory(
&CreateMessagePumpForUI);
CHECK(success) << "Unable to initialize the message pump for Android.";
base::FilePath files_dir(GetTestFilesDirectory(env));
base::FilePath stdout_fifo(files_dir.Append(FILE_PATH_LITERAL("test.fifo")));
EnsureCreateFIFO(stdout_fifo);
base::FilePath stderr_fifo(
files_dir.Append(FILE_PATH_LITERAL("stderr.fifo")));
EnsureCreateFIFO(stderr_fifo);
base::FilePath stdin_fifo(files_dir.Append(FILE_PATH_LITERAL("stdin.fifo")));
EnsureCreateFIFO(stdin_fifo);
success = base::android::RedirectStream(stdout, stdout_fifo, "w") &&
base::android::RedirectStream(stdin, stdin_fifo, "r") &&
base::android::RedirectStream(stderr, stderr_fifo, "w");
CHECK(success) << "Unable to initialize the Android FIFOs.";
}
|
CWE-119
| 184,853 | 5,769 |
170489088470735722613113920229856343107
| null | null | null |
Chrome
|
e1524692d362e607e806569147096dfb8c38cb6a
| 1 |
void ApplyBlockElementCommand::formatSelection(const VisiblePosition& startOfSelection, const VisiblePosition& endOfSelection)
{
Position start = startOfSelection.deepEquivalent().downstream();
if (isAtUnsplittableElement(start)) {
RefPtr<Element> blockquote = createBlockElement();
insertNodeAt(blockquote, start);
RefPtr<Element> placeholder = createBreakElement(document());
appendNode(placeholder, blockquote);
setEndingSelection(VisibleSelection(positionBeforeNode(placeholder.get()), DOWNSTREAM, endingSelection().isDirectional()));
return;
}
RefPtr<Element> blockquoteForNextIndent;
VisiblePosition endOfCurrentParagraph = endOfParagraph(startOfSelection);
VisiblePosition endAfterSelection = endOfParagraph(endOfParagraph(endOfSelection).next());
m_endOfLastParagraph = endOfParagraph(endOfSelection).deepEquivalent();
bool atEnd = false;
Position end;
while (endOfCurrentParagraph != endAfterSelection && !atEnd) {
if (endOfCurrentParagraph.deepEquivalent() == m_endOfLastParagraph)
atEnd = true;
rangeForParagraphSplittingTextNodesIfNeeded(endOfCurrentParagraph, start, end);
endOfCurrentParagraph = end;
Position afterEnd = end.next();
Node* enclosingCell = enclosingNodeOfType(start, &isTableCell);
VisiblePosition endOfNextParagraph = endOfNextParagrahSplittingTextNodesIfNeeded(endOfCurrentParagraph, start, end);
formatRange(start, end, m_endOfLastParagraph, blockquoteForNextIndent);
if (enclosingCell && enclosingCell != enclosingNodeOfType(endOfNextParagraph.deepEquivalent(), &isTableCell))
blockquoteForNextIndent = 0;
if (endAfterSelection.isNotNull() && !endAfterSelection.deepEquivalent().inDocument())
break;
if (endOfNextParagraph.isNotNull() && !endOfNextParagraph.deepEquivalent().inDocument()) {
ASSERT_NOT_REACHED();
return;
}
endOfCurrentParagraph = endOfNextParagraph;
}
}
|
CWE-399
| 184,862 | 5,777 |
53046879309981434195492867638427557877
| null | null | null |
Chrome
|
94bb8861ec61b4ebcce8a4489be2cf7e2a055d90
| 1 |
double ConvolverNode::latencyTime() const
{
return m_reverb ? m_reverb->latencyFrames() / static_cast<double>(sampleRate()) : 0;
}
|
CWE-362
| 184,864 | 5,778 |
146754701753649693802392443766728823316
| null | null | null |
Chrome
|
c2364e0ce42878a2177c6f4cf7adb3c715b777c1
| 1 |
void OmniboxEditModel::RestoreState(const State* state) {
controller_->GetToolbarModel()->set_url_replacement_enabled(
!state || state->url_replacement_enabled);
permanent_text_ = controller_->GetToolbarModel()->GetText();
view_->RevertWithoutResettingSearchTermReplacement();
input_ = state ? state->autocomplete_input : AutocompleteInput();
if (!state)
return;
SetFocusState(state->focus_state, OMNIBOX_FOCUS_CHANGE_TAB_SWITCH);
focus_source_ = state->focus_source;
if (state->user_input_in_progress) {
keyword_ = state->keyword;
is_keyword_hint_ = state->is_keyword_hint;
view_->SetUserText(state->user_text,
DisplayTextFromUserText(state->user_text), false);
view_->SetGrayTextAutocompletion(state->gray_text);
}
}
|
CWE-362
| 184,867 | 5,781 |
36454556757371259516739901222542223911
| null | null | null |
Chrome
|
7edf2c655761e7505950013e62c89e3bd2f7e6dc
| 1 |
ScriptValue ScriptController::executeScriptInMainWorld(const ScriptSourceCode& sourceCode, AccessControlStatus corsStatus)
{
String sourceURL = sourceCode.url();
const String* savedSourceURL = m_sourceURL;
m_sourceURL = &sourceURL;
v8::HandleScope handleScope;
v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_frame);
if (v8Context.IsEmpty())
return ScriptValue();
v8::Context::Scope scope(v8Context);
RefPtr<Frame> protect(m_frame);
v8::Local<v8::Value> object = compileAndRunScript(sourceCode, corsStatus);
m_sourceURL = savedSourceURL;
if (object.IsEmpty())
return ScriptValue();
return ScriptValue(object);
}
| 184,871 | 5,784 |
177218669790837717911279907354317166478
| null | null | null |
|
Chrome
|
248a92c21c20c14b5983680c50e1d8b73fc79a2f
| 1 |
static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& endOfRuns, VisualDirectionOverride override, bool previousLineBrokeCleanly)
{
ASSERT(&topResolver.runs() == &bidiRuns);
ASSERT(topResolver.position() != endOfRuns);
RenderObject* currentRoot = topResolver.position().root();
topResolver.createBidiRunsForLine(endOfRuns, override, previousLineBrokeCleanly);
while (!topResolver.isolatedRuns().isEmpty()) {
BidiRun* isolatedRun = topResolver.isolatedRuns().last();
topResolver.isolatedRuns().removeLast();
RenderObject* startObj = isolatedRun->object();
RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj, currentRoot));
InlineBidiResolver isolatedResolver;
EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi();
TextDirection direction = isolatedInline->style()->direction();
if (unicodeBidi == Plaintext)
direction = determinePlaintextDirectionality(isolatedInline, startObj);
else {
ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride);
direction = isolatedInline->style()->direction();
}
isolatedResolver.setStatus(statusWithDirection(direction, isOverride(unicodeBidi)));
setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startObj);
InlineIterator iter = InlineIterator(isolatedInline, startObj, isolatedRun->m_start);
isolatedResolver.setPositionIgnoringNestedIsolates(iter);
isolatedResolver.createBidiRunsForLine(endOfRuns, NoVisualOverride, previousLineBrokeCleanly);
if (isolatedResolver.runs().runCount())
bidiRuns.replaceRunWithRuns(isolatedRun, isolatedResolver.runs());
if (!isolatedResolver.isolatedRuns().isEmpty()) {
topResolver.isolatedRuns().append(isolatedResolver.isolatedRuns());
isolatedResolver.isolatedRuns().clear();
currentRoot = isolatedInline;
}
}
}
|
CWE-399
| 184,872 | 5,785 |
87961228333894643873497565605699943003
| null | null | null |
Chrome
|
0220f39fac21d169a834ef91de362f4169f2eef5
| 1 |
xsltStylesheetPtr XSLStyleSheet::compileStyleSheet()
{
if (m_embedded)
return xsltLoadStylesheetPI(document());
ASSERT(!m_stylesheetDocTaken);
xsltStylesheetPtr result = xsltParseStylesheetDoc(m_stylesheetDoc);
if (result)
m_stylesheetDocTaken = true;
return result;
}
|
CWE-399
| 184,877 | 5,790 |
67606721734149249817142824523204130971
| null | null | null |
Chrome
|
5ecc8d42ff888ff8b459df566208e7e01a3be5ba
| 1 |
void ColorChooserDialog::DidCloseDialog(bool chose_color,
SkColor color,
RunState run_state) {
if (!listener_)
return;
EndRun(run_state);
CopyCustomColors(custom_colors_, g_custom_colors);
if (chose_color)
listener_->OnColorChosen(color);
listener_->OnColorChooserDialogClosed();
}
|
CWE-399
| 184,879 | 5,791 |
127791017027380400704200317673941091104
| null | null | null |
Chrome
|
47a054e9ad826421b789097d82b44c102ab6ac97
| 1 |
PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
{
const HashSet<Page*>& pages = page->group().pages();
HashSet<Page*>::const_iterator end = pages.end();
for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
Page* otherPage = *it;
if ((deferSelf || otherPage != page)) {
if (!otherPage->defersLoading()) {
m_deferredFrames.append(otherPage->mainFrame());
for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext())
frame->document()->suspendScheduledTasks(ActiveDOMObject::WillDeferLoading);
}
}
}
size_t count = m_deferredFrames.size();
for (size_t i = 0; i < count; ++i)
if (Page* page = m_deferredFrames[i]->page())
page->setDefersLoading(true);
}
| 184,882 | 5,794 |
132804929068837199714646249399089219459
| null | null | null |
|
Chrome
|
6bdf46c517fd12674ffc61d827dc8987e67f0334
| 1 |
ReverbConvolverStage::ReverbConvolverStage(const float* impulseResponse, size_t, size_t reverbTotalLatency, size_t stageOffset, size_t stageLength,
size_t fftSize, size_t renderPhase, size_t renderSliceSize, ReverbAccumulationBuffer* accumulationBuffer, bool directMode)
: m_accumulationBuffer(accumulationBuffer)
, m_accumulationReadIndex(0)
, m_inputReadIndex(0)
, m_directMode(directMode)
{
ASSERT(impulseResponse);
ASSERT(accumulationBuffer);
if (!m_directMode) {
m_fftKernel = adoptPtr(new FFTFrame(fftSize));
m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength);
m_fftConvolver = adoptPtr(new FFTConvolver(fftSize));
} else {
m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2));
m_directKernel->copyToRange(impulseResponse + stageOffset, 0, fftSize / 2);
m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize));
}
m_temporaryBuffer.allocate(renderSliceSize);
size_t totalDelay = stageOffset + reverbTotalLatency;
size_t halfSize = fftSize / 2;
if (!m_directMode) {
ASSERT(totalDelay >= halfSize);
if (totalDelay >= halfSize)
totalDelay -= halfSize;
}
int maxPreDelayLength = std::min(halfSize, totalDelay);
m_preDelayLength = totalDelay > 0 ? renderPhase % maxPreDelayLength : 0;
if (m_preDelayLength > totalDelay)
m_preDelayLength = 0;
m_postDelayLength = totalDelay - m_preDelayLength;
m_preReadWriteIndex = 0;
m_framesProcessed = 0; // total frames processed so far
size_t delayBufferSize = m_preDelayLength < fftSize ? fftSize : m_preDelayLength;
delayBufferSize = delayBufferSize < renderSliceSize ? renderSliceSize : delayBufferSize;
m_preDelayBuffer.allocate(delayBufferSize);
}
|
CWE-119
| 184,883 | 5,795 |
1948827652665011950863664111466562707
| null | null | null |
Chrome
|
3ca8e38ff57e83fcce76f9b54cd8f8bfa09c34ad
| 1 |
bool DoResolveRelativeHost(const char* base_url,
const url_parse::Parsed& base_parsed,
const CHAR* relative_url,
const url_parse::Component& relative_component,
CharsetConverter* query_converter,
CanonOutput* output,
url_parse::Parsed* out_parsed) {
url_parse::Parsed relative_parsed; // Everything but the scheme is valid.
url_parse::ParseAfterScheme(&relative_url[relative_component.begin],
relative_component.len, relative_component.begin,
&relative_parsed);
Replacements<CHAR> replacements;
replacements.SetUsername(relative_url, relative_parsed.username);
replacements.SetPassword(relative_url, relative_parsed.password);
replacements.SetHost(relative_url, relative_parsed.host);
replacements.SetPort(relative_url, relative_parsed.port);
replacements.SetPath(relative_url, relative_parsed.path);
replacements.SetQuery(relative_url, relative_parsed.query);
replacements.SetRef(relative_url, relative_parsed.ref);
return ReplaceStandardURL(base_url, base_parsed, replacements,
query_converter, output, out_parsed);
}
|
CWE-119
| 184,884 | 5,796 |
14662426330022672956226758568478668273
| null | null | null |
Chrome
|
1228817ab04a14df53b5a8446085f9c03bf6e964
| 1 |
void DelegatedFrameHost::CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
const base::Callback<void(bool, const SkBitmap&)>& callback,
const SkColorType color_type) {
bool format_support = ((color_type == kRGB_565_SkColorType) ||
(color_type == kN32_SkColorType));
DCHECK(format_support);
if (!CanCopyToBitmap()) {
callback.Run(false, SkBitmap());
return;
}
const gfx::Size& dst_size_in_pixel =
client_->ConvertViewSizeToPixel(dst_size);
scoped_ptr<cc::CopyOutputRequest> request =
cc::CopyOutputRequest::CreateRequest(base::Bind(
&DelegatedFrameHost::CopyFromCompositingSurfaceHasResult,
dst_size_in_pixel,
color_type,
callback));
gfx::Rect src_subrect_in_pixel =
ConvertRectToPixel(client_->CurrentDeviceScaleFactor(), src_subrect);
request->set_area(src_subrect_in_pixel);
client_->RequestCopyOfOutput(request.Pass());
}
|
CWE-399
| 184,885 | 5,797 |
227983010357763508671465565484799127508
| null | null | null |
Chrome
|
bd3392a1f8b95bf0b0ee3821bc3245d743fb1337
| 1 |
void DateTimeChooserImpl::writeDocument(SharedBuffer* data)
{
String stepString = String::number(m_parameters.step);
String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::TruncateTrailingZeros);
IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_parameters.anchorRectInRootView);
String todayLabelString;
String otherDateLabelString;
if (m_parameters.type == InputTypeNames::month) {
todayLabelString = locale().queryString(WebLocalizedString::ThisMonthButtonLabel);
otherDateLabelString = locale().queryString(WebLocalizedString::OtherMonthLabel);
} else if (m_parameters.type == InputTypeNames::week) {
todayLabelString = locale().queryString(WebLocalizedString::ThisWeekButtonLabel);
otherDateLabelString = locale().queryString(WebLocalizedString::OtherWeekLabel);
} else {
todayLabelString = locale().queryString(WebLocalizedString::CalendarToday);
otherDateLabelString = locale().queryString(WebLocalizedString::OtherDateLabel);
}
addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", data);
data->append(Platform::current()->loadResource("pickerCommon.css"));
data->append(Platform::current()->loadResource("pickerButton.css"));
data->append(Platform::current()->loadResource("suggestionPicker.css"));
data->append(Platform::current()->loadResource("calendarPicker.css"));
addString("</style></head><body><div id=main>Loading...</div><script>\n"
"window.dialogArguments = {\n", data);
addProperty("anchorRectInScreen", anchorRectInScreen, data);
addProperty("min", valueToDateTimeString(m_parameters.minimum, m_parameters.type), data);
addProperty("max", valueToDateTimeString(m_parameters.maximum, m_parameters.type), data);
addProperty("step", stepString, data);
addProperty("stepBase", stepBaseString, data);
addProperty("required", m_parameters.required, data);
addProperty("currentValue", valueToDateTimeString(m_parameters.doubleValue, m_parameters.type), data);
addProperty("locale", m_parameters.locale.string(), data);
addProperty("todayLabel", todayLabelString, data);
addProperty("clearLabel", locale().queryString(WebLocalizedString::CalendarClear), data);
addProperty("weekLabel", locale().queryString(WebLocalizedString::WeekNumberLabel), data);
addProperty("weekStartDay", m_locale->firstDayOfWeek(), data);
addProperty("shortMonthLabels", m_locale->shortMonthLabels(), data);
addProperty("dayLabels", m_locale->weekDayShortLabels(), data);
addProperty("isLocaleRTL", m_locale->isRTL(), data);
addProperty("isRTL", m_parameters.isAnchorElementRTL, data);
addProperty("mode", m_parameters.type.string(), data);
if (m_parameters.suggestions.size()) {
Vector<String> suggestionValues;
Vector<String> localizedSuggestionValues;
Vector<String> suggestionLabels;
for (unsigned i = 0; i < m_parameters.suggestions.size(); i++) {
suggestionValues.append(valueToDateTimeString(m_parameters.suggestions[i].value, m_parameters.type));
localizedSuggestionValues.append(m_parameters.suggestions[i].localizedValue);
suggestionLabels.append(m_parameters.suggestions[i].label);
}
addProperty("suggestionValues", suggestionValues, data);
addProperty("localizedSuggestionValues", localizedSuggestionValues, data);
addProperty("suggestionLabels", suggestionLabels, data);
addProperty("inputWidth", static_cast<unsigned>(m_parameters.anchorRectInRootView.width()), data);
addProperty("showOtherDateEntry", RenderTheme::theme().supportsCalendarPicker(m_parameters.type), data);
addProperty("otherDateLabel", otherDateLabelString, data);
addProperty("suggestionHighlightColor", RenderTheme::theme().activeListBoxSelectionBackgroundColor().serialized(), data);
addProperty("suggestionHighlightTextColor", RenderTheme::theme().activeListBoxSelectionForegroundColor().serialized(), data);
}
addString("}\n", data);
data->append(Platform::current()->loadResource("pickerCommon.js"));
data->append(Platform::current()->loadResource("suggestionPicker.js"));
data->append(Platform::current()->loadResource("calendarPicker.js"));
addString("</script></body>\n", data);
}
|
CWE-22
| 184,888 | 5,800 |
126911034376117665318517103168229992101
| null | null | null |
Chrome
|
afb848acb43ba316097ab4fddfa38dbd80bc6a71
| 1 |
bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
DCHECK_EQ(-1, mapped_file_);
if (options.size == 0) return false;
if (options.size > static_cast<size_t>(std::numeric_limits<int>::max()))
return false;
base::ThreadRestrictions::ScopedAllowIO allow_io;
FILE *fp;
bool fix_size = true;
FilePath path;
if (options.name == NULL || options.name->empty()) {
DCHECK(!options.open_existing);
fp = file_util::CreateAndOpenTemporaryShmemFile(&path, options.executable);
if (fp) {
if (unlink(path.value().c_str()))
PLOG(WARNING) << "unlink";
}
} else {
if (!FilePathForMemoryName(*options.name, &path))
return false;
fp = file_util::OpenFile(path, "w+x");
if (fp == NULL && options.open_existing) {
fp = file_util::OpenFile(path, "a+");
fix_size = false;
}
}
if (fp && fix_size) {
struct stat stat;
if (fstat(fileno(fp), &stat) != 0) {
file_util::CloseFile(fp);
return false;
}
const size_t current_size = stat.st_size;
if (current_size != options.size) {
if (HANDLE_EINTR(ftruncate(fileno(fp), options.size)) != 0) {
file_util::CloseFile(fp);
return false;
}
}
requested_size_ = options.size;
}
if (fp == NULL) {
#if !defined(OS_MACOSX)
PLOG(ERROR) << "Creating shared memory in " << path.value() << " failed";
FilePath dir = path.DirName();
if (access(dir.value().c_str(), W_OK | X_OK) < 0) {
PLOG(ERROR) << "Unable to access(W_OK|X_OK) " << dir.value();
if (dir.value() == "/dev/shm") {
LOG(FATAL) << "This is frequently caused by incorrect permissions on "
<< "/dev/shm. Try 'sudo chmod 1777 /dev/shm' to fix.";
}
}
#else
PLOG(ERROR) << "Creating shared memory in " << path.value() << " failed";
#endif
return false;
}
return PrepareMapFile(fp);
}
|
CWE-264
| 184,889 | 5,801 |
324008768138921697638157734347738807324
| null | null | null |
Chrome
|
4ac8bc08e3306f38a5ab3e551aef6ad43753579c
| 1 |
PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionCode& ec)
{
if (!attrNode) {
ec = TYPE_MISMATCH_ERR;
return 0;
}
RefPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName());
if (oldAttrNode.get() == attrNode)
return attrNode; // This Attr is already attached to the element.
if (attrNode->ownerElement()) {
ec = INUSE_ATTRIBUTE_ERR;
return 0;
}
synchronizeAllAttributes();
UniqueElementData* elementData = ensureUniqueElementData();
size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName());
if (index != notFound) {
if (oldAttrNode)
detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->attributeItem(index)->value());
else
oldAttrNode = Attr::create(document(), attrNode->qualifiedName(), elementData->attributeItem(index)->value());
}
setAttributeInternal(index, attrNode->qualifiedName(), attrNode->value(), NotInSynchronizationOfLazyAttribute);
attrNode->attachToElement(this);
ensureAttrNodeListForElement(this)->append(attrNode);
return oldAttrNode.release();
}
|
CWE-399
| 184,899 | 5,811 |
334106676418220010135344090608884210853
| null | null | null |
Chrome
|
9c18dbcb79e5f700c453d1ac01fb6d8768e4844a
| 1 |
int HttpStreamParser::DoReadHeadersComplete(int result) {
if (result == 0)
result = ERR_CONNECTION_CLOSED;
if (result < 0 && result != ERR_CONNECTION_CLOSED) {
io_state_ = STATE_DONE;
return result;
}
if (result == ERR_CONNECTION_CLOSED && read_buf_->offset() == 0 &&
connection_->is_reused()) {
io_state_ = STATE_DONE;
return result;
}
if (read_buf_->offset() == 0 && result != ERR_CONNECTION_CLOSED)
response_->response_time = base::Time::Now();
if (result == ERR_CONNECTION_CLOSED) {
io_state_ = STATE_DONE;
return ERR_EMPTY_RESPONSE;
} else {
int end_offset;
if (response_header_start_offset_ >= 0) {
io_state_ = STATE_READ_BODY_COMPLETE;
end_offset = read_buf_->offset();
} else {
io_state_ = STATE_BODY_PENDING;
end_offset = 0;
}
int rv = DoParseResponseHeaders(end_offset);
if (rv < 0)
return rv;
return result;
}
}
read_buf_->set_offset(read_buf_->offset() + result);
DCHECK_LE(read_buf_->offset(), read_buf_->capacity());
DCHECK_GE(result, 0);
int end_of_header_offset = ParseResponseHeaders();
if (end_of_header_offset < -1)
return end_of_header_offset;
if (end_of_header_offset == -1) {
io_state_ = STATE_READ_HEADERS;
if (read_buf_->offset() - read_buf_unused_offset_ >= kMaxHeaderBufSize) {
io_state_ = STATE_DONE;
return ERR_RESPONSE_HEADERS_TOO_BIG;
}
} else {
read_buf_unused_offset_ = end_of_header_offset;
if (response_->headers->response_code() / 100 == 1) {
io_state_ = STATE_REQUEST_SENT;
response_header_start_offset_ = -1;
} else {
io_state_ = STATE_BODY_PENDING;
CalculateResponseBodySize();
if (response_body_length_ == 0) {
io_state_ = STATE_DONE;
int extra_bytes = read_buf_->offset() - read_buf_unused_offset_;
if (extra_bytes) {
CHECK_GT(extra_bytes, 0);
memmove(read_buf_->StartOfBuffer(),
read_buf_->StartOfBuffer() + read_buf_unused_offset_,
extra_bytes);
}
read_buf_->SetCapacity(extra_bytes);
read_buf_unused_offset_ = 0;
return OK;
}
}
}
return result;
}
| 184,950 | 5,855 |
18300354792114812604928843511606329555
| null | null | null |
|
Chrome
|
370bd9b522d2ccd4a3113d6c93d30cdf8ca502ef
| 1 |
void WebURLLoaderImpl::Context::OnReceivedResponse(
const ResourceResponseInfo& info) {
if (!client_)
return;
WebURLResponse response;
response.initialize();
PopulateURLResponse(request_.url(), info, &response);
bool show_raw_listing = (GURL(request_.url()).query() == "raw");
if (info.mime_type == "text/vnd.chromium.ftp-dir") {
if (show_raw_listing) {
response.setMIMEType("text/plain");
} else {
response.setMIMEType("text/html");
}
}
client_->didReceiveResponse(loader_, response);
if (!client_)
return;
DCHECK(!ftp_listing_delegate_.get());
DCHECK(!multipart_delegate_.get());
if (info.headers && info.mime_type == "multipart/x-mixed-replace") {
std::string content_type;
info.headers->EnumerateHeader(NULL, "content-type", &content_type);
std::string mime_type;
std::string charset;
bool had_charset = false;
std::string boundary;
net::HttpUtil::ParseContentType(content_type, &mime_type, &charset,
&had_charset, &boundary);
TrimString(boundary, " \"", &boundary);
if (!boundary.empty()) {
multipart_delegate_.reset(
new MultipartResponseDelegate(client_, loader_, response, boundary));
}
} else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
!show_raw_listing) {
ftp_listing_delegate_.reset(
new FtpDirectoryListingResponseDelegate(client_, loader_, response));
}
}
|
CWE-416
| 184,958 | 5,863 |
109821041334681167212328035439806385222
| null | null | null |
Chrome
|
c0da7c1c6e9ffe5006e146b6426f987238d4bf2e
| 1 |
void DevToolsWindow::InspectedContentsClosing() {
web_contents_->GetRenderViewHost()->ClosePage();
}
|
CWE-264
| 184,959 | 5,864 |
290832303710878286064764416424094567906
| null | null | null |
Chrome
|
016da29386308754274675e65fdb73cf9d59dc2d
| 1 |
bool TabsCaptureVisibleTabFunction::RunImpl() {
PrefService* service = profile()->GetPrefs();
if (service->GetBoolean(prefs::kDisableScreenshots)) {
error_ = keys::kScreenshotsDisabled;
return false;
}
WebContents* web_contents = NULL;
if (!GetTabToCapture(&web_contents))
return false;
image_format_ = FORMAT_JPEG; // Default format is JPEG.
image_quality_ = kDefaultQuality; // Default quality setting.
if (HasOptionalArgument(1)) {
DictionaryValue* options = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &options));
if (options->HasKey(keys::kFormatKey)) {
std::string format;
EXTENSION_FUNCTION_VALIDATE(
options->GetString(keys::kFormatKey, &format));
if (format == keys::kFormatValueJpeg) {
image_format_ = FORMAT_JPEG;
} else if (format == keys::kFormatValuePng) {
image_format_ = FORMAT_PNG;
} else {
EXTENSION_FUNCTION_VALIDATE(0);
}
}
if (options->HasKey(keys::kQualityKey)) {
EXTENSION_FUNCTION_VALIDATE(
options->GetInteger(keys::kQualityKey, &image_quality_));
}
}
if (!GetExtension()->CanCaptureVisiblePage(
web_contents->GetURL(),
SessionID::IdForTab(web_contents),
&error_)) {
return false;
}
RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
content::RenderWidgetHostView* view = render_view_host->GetView();
if (!view) {
error_ = keys::kInternalVisibleTabCaptureError;
return false;
}
render_view_host->CopyFromBackingStore(
gfx::Rect(),
view->GetViewBounds().size(),
base::Bind(&TabsCaptureVisibleTabFunction::CopyFromBackingStoreComplete,
this));
return true;
}
|
CWE-264
| 184,960 | 5,865 |
285077923452161423018193269046097310193
| null | null | null |
Chrome
|
09fbb829eab7ee25e90bb4e9c2f4973c6c62d0f3
| 1 |
bool SimplifiedBackwardsTextIterator::handleTextNode()
{
m_lastTextNode = m_node;
int startOffset;
int offsetInNode;
RenderText* renderer = handleFirstLetter(startOffset, offsetInNode);
if (!renderer)
return true;
String text = renderer->text();
if (!renderer->firstTextBox() && text.length() > 0)
return true;
m_positionEndOffset = m_offset;
m_offset = startOffset + offsetInNode;
m_positionNode = m_node;
m_positionStartOffset = m_offset;
ASSERT(0 <= m_positionStartOffset - offsetInNode && m_positionStartOffset - offsetInNode <= static_cast<int>(text.length()));
ASSERT(1 <= m_positionEndOffset - offsetInNode && m_positionEndOffset - offsetInNode <= static_cast<int>(text.length()));
ASSERT(m_positionStartOffset <= m_positionEndOffset);
m_textLength = m_positionEndOffset - m_positionStartOffset;
m_textCharacters = text.characters() + (m_positionStartOffset - offsetInNode);
ASSERT(m_textCharacters >= text.characters());
ASSERT(m_textCharacters + m_textLength <= text.characters() + static_cast<int>(text.length()));
m_lastCharacter = text[m_positionEndOffset - 1];
return !m_shouldHandleFirstLetter;
}
|
CWE-119
| 185,007 | 5,906 |
316326951134461383904426638785212537043
| null | null | null |
Chrome
|
6f62e3b41fe9ef708aa8c990dd814ae91d68f2f4
| 1 |
PlatformFileForTransit GetFileHandleForProcess(base::PlatformFile handle,
base::ProcessHandle process,
bool close_source_handle) {
IPC::PlatformFileForTransit out_handle;
#if defined(OS_WIN)
DWORD options = DUPLICATE_SAME_ACCESS;
if (close_source_handle)
options |= DUPLICATE_CLOSE_SOURCE;
if (!::DuplicateHandle(::GetCurrentProcess(),
handle,
process,
&out_handle,
0,
FALSE,
options)) {
out_handle = IPC::InvalidPlatformFileForTransit();
}
#elif defined(OS_POSIX)
int fd = close_source_handle ? handle : ::dup(handle);
out_handle = base::FileDescriptor(fd, true);
#else
#error Not implemented.
#endif
return out_handle;
}
| 185,012 | 5,910 |
262490405011844981119906128938421688010
| null | null | null |
|
Chrome
|
7d085fbb43b21e959900b94f191588fd10546a94
| 1 |
void ImageLoader::updateFromElement()
{
Document* document = m_element->document();
if (!document->renderer())
return;
AtomicString attr = m_element->imageSourceURL();
if (attr == m_failedLoadURL)
return;
CachedResourceHandle<CachedImage> newImage = 0;
if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
CachedResourceRequest request(ResourceRequest(document->completeURL(sourceURI(attr))));
request.setInitiator(element());
String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr);
if (!crossOriginMode.isNull()) {
StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
updateRequestForAccessControl(request.mutableResourceRequest(), document->securityOrigin(), allowCredentials);
}
if (m_loadManually) {
bool autoLoadOtherImages = document->cachedResourceLoader()->autoLoadImages();
document->cachedResourceLoader()->setAutoLoadImages(false);
newImage = new CachedImage(request.resourceRequest());
newImage->setLoading(true);
newImage->setOwningCachedResourceLoader(document->cachedResourceLoader());
document->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage.get());
document->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages);
} else
newImage = document->cachedResourceLoader()->requestImage(request);
if (!newImage && !pageIsBeingDismissed(document)) {
m_failedLoadURL = attr;
m_hasPendingErrorEvent = true;
errorEventSender().dispatchEventSoon(this);
} else
clearFailedLoadURL();
} else if (!attr.isNull()) {
m_element->dispatchEvent(Event::create(eventNames().errorEvent, false, false));
}
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
if (m_hasPendingBeforeLoadEvent) {
beforeLoadEventSender().cancelEvent(this);
m_hasPendingBeforeLoadEvent = false;
}
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
}
if (m_hasPendingErrorEvent && newImage) {
errorEventSender().cancelEvent(this);
m_hasPendingErrorEvent = false;
}
m_image = newImage;
m_hasPendingBeforeLoadEvent = !m_element->document()->isImageDocument() && newImage;
m_hasPendingLoadEvent = newImage;
m_imageComplete = !newImage;
if (newImage) {
if (!m_element->document()->isImageDocument()) {
if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
dispatchPendingBeforeLoadEvent();
else
beforeLoadEventSender().dispatchEventSoon(this);
} else
updateRenderer();
newImage->addClient(this);
}
if (oldImage)
oldImage->removeClient(this);
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
updatedHasPendingEvent();
}
|
CWE-416
| 185,017 | 5,915 |
39898491843170125626564329570787826944
| null | null | null |
Chrome
|
4801ff6578b3976731b13657715dcbe916c6a221
| 1 |
bool V8DOMWindow::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType type, v8::Local<v8::Value>)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Object> window = host->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(isolate, worldTypeInMainThread(isolate)));
if (window.IsEmpty())
return false; // the frame is gone.
DOMWindow* targetWindow = V8DOMWindow::toNative(window);
ASSERT(targetWindow);
Frame* target = targetWindow->frame();
if (!target)
return false;
if (target->loader()->stateMachine()->isDisplayingInitialEmptyDocument())
target->loader()->didAccessInitialDocument();
if (key->IsString()) {
DEFINE_STATIC_LOCAL(AtomicString, nameOfProtoProperty, ("__proto__", AtomicString::ConstructFromLiteral));
String name = toWebCoreString(key);
Frame* childFrame = target->tree()->scopedChild(name);
if (type == v8::ACCESS_HAS && childFrame)
return true;
if (type == v8::ACCESS_GET && childFrame && !host->HasRealNamedProperty(key->ToString()) && name != nameOfProtoProperty)
return true;
}
return BindingSecurity::shouldAllowAccessToFrame(target, DoNotReportSecurityError);
}
| 185,033 | 5,930 |
329332566965424656831499943555682759513
| null | null | null |
|
Chrome
|
a3b76c8c13ea6b228122440f48c61b66d20443dd
| 1 |
void CreateAuthenticatorFactory() {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
std::string local_certificate = key_pair_.GenerateCertificate();
if (local_certificate.empty()) {
LOG(ERROR) << "Failed to generate host certificate.";
Shutdown(kHostInitializationFailed);
return;
}
scoped_ptr<protocol::AuthenticatorFactory> factory(
new protocol::Me2MeHostAuthenticatorFactory(
local_certificate, *key_pair_.private_key(), host_secret_hash_));
host_->SetAuthenticatorFactory(factory.Pass());
}
|
CWE-119
| 185,036 | 5,933 |
269116711744518033023899846134822889160
| null | null | null |
Chrome
|
7df06970ff05d4b412534f6deea89c9b9ac4be67
| 1 |
void PPB_Buffer_Proxy::OnMsgCreate(
PP_Instance instance,
uint32_t size,
HostResource* result_resource,
ppapi::proxy::SerializedHandle* result_shm_handle) {
result_shm_handle->set_null_shmem();
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
thunk::EnterResourceCreation enter(instance);
if (enter.failed())
return;
PP_Resource local_buffer_resource = enter.functions()->CreateBuffer(instance,
size);
if (local_buffer_resource == 0)
return;
thunk::EnterResourceNoLock<thunk::PPB_BufferTrusted_API> trusted_buffer(
local_buffer_resource, false);
if (trusted_buffer.failed())
return;
int local_fd;
if (trusted_buffer.object()->GetSharedMemory(&local_fd) != PP_OK)
return;
result_resource->SetHostResource(instance, local_buffer_resource);
base::PlatformFile platform_file =
#if defined(OS_WIN)
reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd));
#elif defined(OS_POSIX)
local_fd;
#else
#error Not implemented.
#endif
result_shm_handle->set_shmem(
dispatcher->ShareHandleWithRemote(platform_file, false), size);
}
|
CWE-399
| 185,039 | 5,936 |
190931248690685799782207820986089809784
| null | null | null |
Chrome
|
634c5943f46abe8c6280079f6d394dfee08c3c8f
| 1 |
void RenderLayerCompositor::frameViewDidScroll()
{
FrameView* frameView = m_renderView->frameView();
IntPoint scrollPosition = frameView->scrollPosition();
if (!m_scrollLayer)
return;
bool scrollingCoordinatorHandlesOffset = false;
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) {
if (Settings* settings = m_renderView->document().settings()) {
if (isMainFrame() || settings->compositedScrollingForFramesEnabled())
scrollingCoordinatorHandlesOffset = scrollingCoordinator->scrollableAreaScrollLayerDidChange(frameView);
}
}
if (scrollingCoordinatorHandlesOffset)
m_scrollLayer->setPosition(-frameView->minimumScrollPosition());
else
m_scrollLayer->setPosition(-scrollPosition);
blink::Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBackground",
ScrolledMainFrameBucket,
AcceleratedFixedRootBackgroundHistogramMax);
if (!m_renderView->rootBackgroundIsEntirelyFixed())
return;
blink::Platform::current()->histogramEnumeration("Renderer.AcceleratedFixedRootBackground",
!!fixedRootBackgroundLayer()
? ScrolledMainFrameWithAcceleratedFixedRootBackground
: ScrolledMainFrameWithUnacceleratedFixedRootBackground,
AcceleratedFixedRootBackgroundHistogramMax);
}
|
CWE-20
| 185,040 | 5,937 |
277930543007255641493624600353195979164
| null | null | null |
Chrome
|
25f9415f43d607d3d01f542f067e3cc471983e6b
| 1 |
bool HTMLFormControlElement::isAutofocusable() const
{
if (!fastHasAttribute(autofocusAttr))
return false;
if (hasTagName(inputTag))
return !toHTMLInputElement(this)->isInputTypeHidden();
if (hasTagName(selectTag))
return true;
if (hasTagName(keygenTag))
return true;
if (hasTagName(buttonTag))
return true;
if (hasTagName(textareaTag))
return true;
return false;
}
|
CWE-119
| 185,041 | 5,938 |
278129671042807527769549287627575402125
| null | null | null |
Chrome
|
1538367452b549d929aabb13d54c85ab99f65cd3
| 1 |
bool ChromeDownloadManagerDelegate::IsDangerousFile(
const DownloadItem& download,
const FilePath& suggested_path,
bool visited_referrer_before) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (download.GetTransitionType() & content::PAGE_TRANSITION_FROM_ADDRESS_BAR)
return false;
if (extensions::FeatureSwitch::easy_off_store_install()->IsEnabled() &&
download_crx_util::IsExtensionDownload(download) &&
!extensions::WebstoreInstaller::GetAssociatedApproval(download)) {
return true;
}
if (ShouldOpenFileBasedOnExtension(suggested_path) &&
download.HasUserGesture())
return false;
download_util::DownloadDangerLevel danger_level =
download_util::GetFileDangerLevel(suggested_path.BaseName());
if (danger_level == download_util::AllowOnUserGesture)
return !download.HasUserGesture() || !visited_referrer_before;
return danger_level == download_util::Dangerous;
}
|
CWE-264
| 185,091 | 5,982 |
94225698097387477629984957402061472591
| null | null | null |
Chrome
|
d443be6fdfe17ca4f3ff1843ded362ff0cd01096
| 1 |
void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
std::string command(cmd); // Make a local copy so we can modify it.
if (command.length() > 1 && command[0] == '"') {
command = command.substr(1, command.length() - 2);
}
RecordUserReactionTime(command);
if (command == kDoReportCommand) {
SetReportingPreference(true);
return;
}
if (command == kDontReportCommand) {
SetReportingPreference(false);
return;
}
if (command == kLearnMoreCommand) {
GURL url;
SBThreatType threat_type = unsafe_resources_[0].threat_type;
if (threat_type == SB_THREAT_TYPE_URL_MALWARE) {
url = google_util::AppendGoogleLocaleParam(GURL(kLearnMoreMalwareUrl));
} else if (threat_type == SB_THREAT_TYPE_URL_PHISHING ||
threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) {
url = google_util::AppendGoogleLocaleParam(GURL(kLearnMorePhishingUrl));
} else {
NOTREACHED();
}
OpenURLParams params(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
return;
}
if (command == kLearnMoreCommandV2) {
GURL url;
SBThreatType threat_type = unsafe_resources_[0].threat_type;
if (threat_type == SB_THREAT_TYPE_URL_MALWARE) {
url = google_util::AppendGoogleLocaleParam(GURL(kLearnMoreMalwareUrlV2));
} else if (threat_type == SB_THREAT_TYPE_URL_PHISHING ||
threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) {
url = google_util::AppendGoogleLocaleParam(GURL(kLearnMorePhishingUrlV2));
} else {
NOTREACHED();
}
OpenURLParams params(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
return;
}
if (command == kShowPrivacyCommand) {
GURL url(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL));
OpenURLParams params(
url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false);
web_contents_->OpenURL(params);
return;
}
bool proceed_blocked = false;
if (command == kProceedCommand) {
if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) {
proceed_blocked = true;
} else {
interstitial_page_->Proceed();
return;
}
}
if (command == kTakeMeBackCommand || proceed_blocked) {
if (is_main_frame_load_blocked_) {
interstitial_page_->DontProceed();
return;
}
if (web_contents_->GetController().CanGoBack()) {
web_contents_->GetController().GoBack();
} else {
web_contents_->GetController().LoadURL(
GURL(chrome::kChromeUINewTabURL),
content::Referrer(),
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
}
return;
}
int element_index = 0;
size_t colon_index = command.find(':');
if (colon_index != std::string::npos) {
DCHECK(colon_index < command.size() - 1);
bool result = base::StringToInt(base::StringPiece(command.begin() +
colon_index + 1,
command.end()),
&element_index);
command = command.substr(0, colon_index);
DCHECK(result);
}
if (element_index >= static_cast<int>(unsafe_resources_.size())) {
NOTREACHED();
return;
}
std::string bad_url_spec = unsafe_resources_[element_index].url.spec();
if (command == kReportErrorCommand) {
SBThreatType threat_type = unsafe_resources_[element_index].threat_type;
DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING ||
threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL);
GURL report_url =
safe_browsing_util::GeneratePhishingReportUrl(
kSbReportPhishingErrorUrl,
bad_url_spec,
threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL);
OpenURLParams params(
report_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
false);
web_contents_->OpenURL(params);
return;
}
if (command == kShowDiagnosticCommand) {
std::string diagnostic =
base::StringPrintf(kSbDiagnosticUrl,
net::EscapeQueryParamValue(bad_url_spec, true).c_str());
GURL diagnostic_url(diagnostic);
diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url);
DCHECK(unsafe_resources_[element_index].threat_type ==
SB_THREAT_TYPE_URL_MALWARE);
OpenURLParams params(
diagnostic_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK,
false);
web_contents_->OpenURL(params);
return;
}
if (command == kExpandedSeeMore) {
return;
}
NOTREACHED() << "Unexpected command: " << command;
}
|
CWE-119
| 185,094 | 5,985 |
101298675478786661406645534909081184606
| null | null | null |
Chrome
|
3b2943f5d343f5da393b99fe9efe6cefc6856aa1
| 1 |
void SavePackage::OnReceivedSavableResourceLinksForCurrentPage(
const std::vector<GURL>& resources_list,
const std::vector<Referrer>& referrers_list,
const std::vector<GURL>& frames_list) {
if (wait_state_ != RESOURCES_LIST)
return;
DCHECK(resources_list.size() == referrers_list.size());
all_save_items_count_ = static_cast<int>(resources_list.size()) +
static_cast<int>(frames_list.size());
if (download_ && download_->IsInProgress())
download_->SetTotalBytes(all_save_items_count_);
if (all_save_items_count_) {
for (int i = 0; i < static_cast<int>(resources_list.size()); ++i) {
const GURL& u = resources_list[i];
DCHECK(u.is_valid());
SaveFileCreateInfo::SaveFileSource save_source = u.SchemeIsFile() ?
SaveFileCreateInfo::SAVE_FILE_FROM_FILE :
SaveFileCreateInfo::SAVE_FILE_FROM_NET;
SaveItem* save_item = new SaveItem(u, referrers_list[i],
this, save_source);
waiting_item_queue_.push(save_item);
}
for (int i = 0; i < static_cast<int>(frames_list.size()); ++i) {
const GURL& u = frames_list[i];
DCHECK(u.is_valid());
SaveItem* save_item = new SaveItem(
u, Referrer(), this, SaveFileCreateInfo::SAVE_FILE_FROM_DOM);
waiting_item_queue_.push(save_item);
}
wait_state_ = NET_FILES;
DoSavingProcess();
} else {
Cancel(true);
}
}
| 185,098 | 5,989 |
160063975068343725173547461969527145055
| null | null | null |
|
Chrome
|
42d87b0bec018634ec81a72d3b265f3138d75e1d
| 1 |
PP_Flash_Menu* ReadMenu(int depth,
const IPC::Message* m,
PickleIterator* iter) {
if (depth > kMaxMenuDepth)
return NULL;
++depth;
PP_Flash_Menu* menu = new PP_Flash_Menu;
menu->items = NULL;
if (!m->ReadUInt32(iter, &menu->count)) {
FreeMenu(menu);
return NULL;
}
if (menu->count == 0)
return menu;
menu->items = new PP_Flash_MenuItem[menu->count];
memset(menu->items, 0, sizeof(PP_Flash_MenuItem) * menu->count);
for (uint32_t i = 0; i < menu->count; ++i) {
if (!ReadMenuItem(depth, m, iter, menu->items + i)) {
FreeMenu(menu);
return NULL;
}
}
return menu;
}
| 185,099 | 5,990 |
334328269208845425005478287014367474305
| null | null | null |
|
Chrome
|
ed6f4545a2a345697e07908c887333f5bdcc97a3
| 1 |
void ScriptLoader::executeScript(const ScriptSourceCode& sourceCode)
{
ASSERT(m_alreadyStarted);
if (sourceCode.isEmpty())
return;
RefPtr<Document> elementDocument(m_element->document());
RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
if (!contextDocument)
return;
LocalFrame* frame = contextDocument->frame();
bool shouldBypassMainWorldContentSecurityPolicy = (frame && frame->script().shouldBypassMainWorldContentSecurityPolicy()) || elementDocument->contentSecurityPolicy()->allowScriptNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)) || elementDocument->contentSecurityPolicy()->allowScriptHash(sourceCode.source());
if (!m_isExternalScript && (!shouldBypassMainWorldContentSecurityPolicy && !elementDocument->contentSecurityPolicy()->allowInlineScript(elementDocument->url(), m_startLineNumber)))
return;
if (m_isExternalScript && m_resource && !m_resource->mimeTypeAllowedByNosniff()) {
contextDocument->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Refused to execute script from '" + m_resource->url().elidedString() + "' because its MIME type ('" + m_resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
return;
}
if (frame) {
const bool isImportedScript = contextDocument != elementDocument;
IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrementer(m_isExternalScript || isImportedScript ? contextDocument.get() : 0);
if (isHTMLScriptLoader(m_element))
contextDocument->pushCurrentScript(toHTMLScriptElement(m_element));
AccessControlStatus corsCheck = NotSharableCrossOrigin;
if (sourceCode.resource() && sourceCode.resource()->passesAccessControlCheck(m_element->document().securityOrigin()))
corsCheck = SharableCrossOrigin;
frame->script().executeScriptInMainWorld(sourceCode, corsCheck);
if (isHTMLScriptLoader(m_element)) {
ASSERT(contextDocument->currentScript() == m_element);
contextDocument->popCurrentScript();
}
}
}
|
CWE-362
| 185,106 | 5,996 |
220693054393959484132888743339801122989
| null | null | null |
Chrome
|
23803a58e481e464a787e4b2c461af9e62f03905
| 1 |
bool CopyDirectory(const FilePath& from_path,
const FilePath& to_path,
bool recursive) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(to_path.value().find('*') == std::string::npos);
DCHECK(from_path.value().find('*') == std::string::npos);
char top_dir[PATH_MAX];
if (base::strlcpy(top_dir, from_path.value().c_str(),
arraysize(top_dir)) >= arraysize(top_dir)) {
return false;
}
FilePath real_to_path = to_path;
if (PathExists(real_to_path)) {
if (!AbsolutePath(&real_to_path))
return false;
} else {
real_to_path = real_to_path.DirName();
if (!AbsolutePath(&real_to_path))
return false;
}
FilePath real_from_path = from_path;
if (!AbsolutePath(&real_from_path))
return false;
if (real_to_path.value().size() >= real_from_path.value().size() &&
real_to_path.value().compare(0, real_from_path.value().size(),
real_from_path.value()) == 0)
return false;
bool success = true;
int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS;
if (recursive)
traverse_type |= FileEnumerator::DIRECTORIES;
FileEnumerator traversal(from_path, recursive, traverse_type);
FileEnumerator::FindInfo info;
FilePath current = from_path;
if (stat(from_path.value().c_str(), &info.stat) < 0) {
DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: "
<< from_path.value() << " errno = " << errno;
success = false;
}
struct stat to_path_stat;
FilePath from_path_base = from_path;
if (recursive && stat(to_path.value().c_str(), &to_path_stat) == 0 &&
S_ISDIR(to_path_stat.st_mode)) {
from_path_base = from_path.DirName();
}
DCHECK(recursive || S_ISDIR(info.stat.st_mode));
while (success && !current.empty()) {
std::string suffix(¤t.value().c_str()[from_path_base.value().size()]);
if (!suffix.empty()) {
DCHECK_EQ('/', suffix[0]);
suffix.erase(0, 1);
}
const FilePath target_path = to_path.Append(suffix);
if (S_ISDIR(info.stat.st_mode)) {
if (mkdir(target_path.value().c_str(), info.stat.st_mode & 01777) != 0 &&
errno != EEXIST) {
DLOG(ERROR) << "CopyDirectory() couldn't create directory: "
<< target_path.value() << " errno = " << errno;
success = false;
}
} else if (S_ISREG(info.stat.st_mode)) {
if (!CopyFile(current, target_path)) {
DLOG(ERROR) << "CopyDirectory() couldn't create file: "
<< target_path.value();
success = false;
}
} else {
DLOG(WARNING) << "CopyDirectory() skipping non-regular file: "
<< current.value();
}
current = traversal.Next();
traversal.GetFindInfo(&info);
}
return success;
}
|
CWE-22
| 185,107 | 5,997 |
191402501457525070238119379390154556968
| null | null | null |
Chrome
|
12baa2097220e33c12b60aa5e6da6701637761bf
| 1 |
void BookmarksIOFunction::ShowSelectFileDialog(
ui::SelectFileDialog::Type type,
const base::FilePath& default_path) {
AddRef();
WebContents* web_contents = dispatcher()->delegate()->
GetAssociatedWebContents();
select_file_dialog_ = ui::SelectFileDialog::Create(
this, new ChromeSelectFilePolicy(web_contents));
ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.resize(1);
file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html"));
if (type == ui::SelectFileDialog::SELECT_OPEN_FILE)
file_type_info.support_drive = true;
select_file_dialog_->SelectFile(type,
string16(),
default_path,
&file_type_info,
0,
FILE_PATH_LITERAL(""),
NULL,
NULL);
}
|
CWE-399
| 185,133 | 6,019 |
48717565889459823547391583274690925279
| null | null | null |
Chrome
|
28aaa72a03df96fa1934876b0efbbc7e6b4b38af
| 1 |
bool ResourceDispatcherHostImpl::AcceptAuthRequest(
ResourceLoader* loader,
net::AuthChallengeInfo* auth_info) {
if (delegate_ && !delegate_->AcceptAuthRequest(loader->request(), auth_info))
return false;
if (!auth_info->is_proxy) {
HttpAuthResourceType resource_type =
HttpAuthResourceTypeOf(loader->request());
UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthResource",
resource_type,
HTTP_AUTH_RESOURCE_LAST);
if (resource_type == HTTP_AUTH_RESOURCE_BLOCKED_CROSS)
return false;
}
return true;
}
|
CWE-264
| 185,137 | 6,023 |
66539345592789228103996472543990848092
| null | null | null |
Chrome
|
a9ca2310c6e68ad8dc39d6b54ca9ea10867ed8a1
| 1 |
static blink::WebScreenOrientations stringToOrientations(const AtomicString& orientationString)
{
DEFINE_STATIC_LOCAL(const AtomicString, portrait, ("portrait", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(const AtomicString, landscape, ("landscape", AtomicString::ConstructFromLiteral));
if (orientationString == portrait)
return blink::WebScreenOrientationPortraitPrimary | blink::WebScreenOrientationPortraitSecondary;
if (orientationString == landscape)
return blink::WebScreenOrientationLandscapePrimary | blink::WebScreenOrientationLandscapeSecondary;
unsigned length = 0;
ScreenOrientationInfo* orientationMap = orientationsMap(length);
for (unsigned i = 0; i < length; ++i) {
if (orientationMap[i].name == orientationString)
return orientationMap[i].orientation;
}
return 0;
}
|
CWE-119
| 185,138 | 6,024 |
286179830601049429032214292571900624780
| null | null | null |
Chrome
|
52a30db57ecec68bb3b25fdc3de5e9bee7b80ed7
| 1 |
void WebPreferences::Apply(WebView* web_view) const {
WebSettings* settings = web_view->settings();
ApplyFontsFromMap(standard_font_family_map, setStandardFontFamilyWrapper,
settings);
ApplyFontsFromMap(fixed_font_family_map, setFixedFontFamilyWrapper, settings);
ApplyFontsFromMap(serif_font_family_map, setSerifFontFamilyWrapper, settings);
ApplyFontsFromMap(sans_serif_font_family_map, setSansSerifFontFamilyWrapper,
settings);
ApplyFontsFromMap(cursive_font_family_map, setCursiveFontFamilyWrapper,
settings);
ApplyFontsFromMap(fantasy_font_family_map, setFantasyFontFamilyWrapper,
settings);
ApplyFontsFromMap(pictograph_font_family_map, setPictographFontFamilyWrapper,
settings);
settings->setDefaultFontSize(default_font_size);
settings->setDefaultFixedFontSize(default_fixed_font_size);
settings->setMinimumFontSize(minimum_font_size);
settings->setMinimumLogicalFontSize(minimum_logical_font_size);
settings->setDefaultTextEncodingName(ASCIIToUTF16(default_encoding));
settings->setApplyDefaultDeviceScaleFactorInCompositor(
apply_default_device_scale_factor_in_compositor);
settings->setApplyPageScaleFactorInCompositor(
apply_page_scale_factor_in_compositor);
settings->setPerTilePaintingEnabled(per_tile_painting_enabled);
settings->setAcceleratedAnimationEnabled(accelerated_animation_enabled);
settings->setJavaScriptEnabled(javascript_enabled);
settings->setWebSecurityEnabled(web_security_enabled);
settings->setJavaScriptCanOpenWindowsAutomatically(
javascript_can_open_windows_automatically);
settings->setLoadsImagesAutomatically(loads_images_automatically);
settings->setImagesEnabled(images_enabled);
settings->setPluginsEnabled(plugins_enabled);
settings->setDOMPasteAllowed(dom_paste_enabled);
settings->setDeveloperExtrasEnabled(developer_extras_enabled);
settings->setNeedsSiteSpecificQuirks(site_specific_quirks_enabled);
settings->setShrinksStandaloneImagesToFit(shrinks_standalone_images_to_fit);
settings->setUsesEncodingDetector(uses_universal_detector);
settings->setTextAreasAreResizable(text_areas_are_resizable);
settings->setAllowScriptsToCloseWindows(allow_scripts_to_close_windows);
if (user_style_sheet_enabled)
settings->setUserStyleSheetLocation(user_style_sheet_location);
else
settings->setUserStyleSheetLocation(WebURL());
settings->setAuthorAndUserStylesEnabled(author_and_user_styles_enabled);
settings->setUsesPageCache(uses_page_cache);
settings->setPageCacheSupportsPlugins(page_cache_supports_plugins);
settings->setDownloadableBinaryFontsEnabled(remote_fonts_enabled);
settings->setJavaScriptCanAccessClipboard(javascript_can_access_clipboard);
settings->setXSSAuditorEnabled(xss_auditor_enabled);
settings->setDNSPrefetchingEnabled(dns_prefetching_enabled);
settings->setLocalStorageEnabled(local_storage_enabled);
settings->setSyncXHRInDocumentsEnabled(sync_xhr_in_documents_enabled);
WebRuntimeFeatures::enableDatabase(databases_enabled);
settings->setOfflineWebApplicationCacheEnabled(application_cache_enabled);
settings->setCaretBrowsingEnabled(caret_browsing_enabled);
settings->setHyperlinkAuditingEnabled(hyperlink_auditing_enabled);
settings->setCookieEnabled(cookie_enabled);
settings->setEditableLinkBehaviorNeverLive();
settings->setFrameFlatteningEnabled(frame_flattening_enabled);
settings->setFontRenderingModeNormal();
settings->setJavaEnabled(java_enabled);
settings->setAllowUniversalAccessFromFileURLs(
allow_universal_access_from_file_urls);
settings->setAllowFileAccessFromFileURLs(allow_file_access_from_file_urls);
settings->setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
settings->setWebAudioEnabled(webaudio_enabled);
settings->setExperimentalWebGLEnabled(experimental_webgl_enabled);
settings->setOpenGLMultisamplingEnabled(gl_multisampling_enabled);
settings->setPrivilegedWebGLExtensionsEnabled(
privileged_webgl_extensions_enabled);
settings->setWebGLErrorsToConsoleEnabled(webgl_errors_to_console_enabled);
settings->setShowDebugBorders(show_composited_layer_borders);
settings->setShowFPSCounter(show_fps_counter);
settings->setAcceleratedCompositingForOverflowScrollEnabled(
accelerated_compositing_for_overflow_scroll_enabled);
settings->setAcceleratedCompositingForScrollableFramesEnabled(
accelerated_compositing_for_scrollable_frames_enabled);
settings->setCompositedScrollingForFramesEnabled(
composited_scrolling_for_frames_enabled);
settings->setShowPlatformLayerTree(show_composited_layer_tree);
settings->setShowPaintRects(show_paint_rects);
settings->setRenderVSyncEnabled(render_vsync_enabled);
settings->setAcceleratedCompositingEnabled(accelerated_compositing_enabled);
settings->setAcceleratedCompositingForFixedPositionEnabled(
fixed_position_compositing_enabled);
settings->setAccelerated2dCanvasEnabled(accelerated_2d_canvas_enabled);
settings->setDeferred2dCanvasEnabled(deferred_2d_canvas_enabled);
settings->setAntialiased2dCanvasEnabled(!antialiased_2d_canvas_disabled);
settings->setAcceleratedPaintingEnabled(accelerated_painting_enabled);
settings->setAcceleratedFiltersEnabled(accelerated_filters_enabled);
settings->setGestureTapHighlightEnabled(gesture_tap_highlight_enabled);
settings->setAcceleratedCompositingFor3DTransformsEnabled(
accelerated_compositing_for_3d_transforms_enabled);
settings->setAcceleratedCompositingForVideoEnabled(
accelerated_compositing_for_video_enabled);
settings->setAcceleratedCompositingForAnimationEnabled(
accelerated_compositing_for_animation_enabled);
settings->setAcceleratedCompositingForPluginsEnabled(
accelerated_compositing_for_plugins_enabled);
settings->setAcceleratedCompositingForCanvasEnabled(
experimental_webgl_enabled || accelerated_2d_canvas_enabled);
settings->setMemoryInfoEnabled(memory_info_enabled);
settings->setAsynchronousSpellCheckingEnabled(
asynchronous_spell_checking_enabled);
settings->setUnifiedTextCheckerEnabled(unified_textchecker_enabled);
for (WebInspectorPreferences::const_iterator it = inspector_settings.begin();
it != inspector_settings.end(); ++it)
web_view->setInspectorSetting(WebString::fromUTF8(it->first),
WebString::fromUTF8(it->second));
web_view->setTabsToLinks(tabs_to_links);
settings->setInteractiveFormValidationEnabled(true);
settings->setFullScreenEnabled(fullscreen_enabled);
settings->setAllowDisplayOfInsecureContent(allow_displaying_insecure_content);
settings->setAllowRunningOfInsecureContent(allow_running_insecure_content);
settings->setPasswordEchoEnabled(password_echo_enabled);
settings->setShouldPrintBackgrounds(should_print_backgrounds);
settings->setEnableScrollAnimator(enable_scroll_animator);
settings->setVisualWordMovementEnabled(visual_word_movement_enabled);
settings->setCSSStickyPositionEnabled(css_sticky_position_enabled);
settings->setExperimentalCSSCustomFilterEnabled(css_shaders_enabled);
settings->setExperimentalCSSVariablesEnabled(css_variables_enabled);
settings->setExperimentalCSSGridLayoutEnabled(css_grid_layout_enabled);
WebRuntimeFeatures::enableTouch(touch_enabled);
settings->setDeviceSupportsTouch(device_supports_touch);
settings->setDeviceSupportsMouse(device_supports_mouse);
settings->setEnableTouchAdjustment(touch_adjustment_enabled);
settings->setDefaultTileSize(
WebSize(default_tile_width, default_tile_height));
settings->setMaxUntiledLayerSize(
WebSize(max_untiled_layer_width, max_untiled_layer_height));
settings->setFixedPositionCreatesStackingContext(
fixed_position_creates_stacking_context);
settings->setDeferredImageDecodingEnabled(deferred_image_decoding_enabled);
settings->setShouldRespectImageOrientation(should_respect_image_orientation);
settings->setEditingBehavior(
static_cast<WebSettings::EditingBehavior>(editing_behavior));
settings->setSupportsMultipleWindows(supports_multiple_windows);
settings->setViewportEnabled(viewport_enabled);
#if defined(OS_ANDROID)
settings->setAllowCustomScrollbarInMainFrame(false);
settings->setTextAutosizingEnabled(text_autosizing_enabled);
settings->setTextAutosizingFontScaleFactor(font_scale_factor);
web_view->setIgnoreViewportTagMaximumScale(force_enable_zoom);
settings->setAutoZoomFocusedNodeToLegibleScale(true);
settings->setDoubleTapToZoomEnabled(true);
settings->setMediaPlaybackRequiresUserGesture(
user_gesture_required_for_media_playback);
#endif
WebNetworkStateNotifier::setOnLine(is_online);
}
|
CWE-20
| 185,155 | 6,039 |
302887036079995387599401167236814237289
| null | null | null |
Chrome
|
faceb51d5058e1159835a4b0cd65081bb0a9de1e
| 1 |
void WebRuntimeFeatures::enableSpeechSynthesis(bool enable)
{
RuntimeEnabledFeatures::setSpeechSynthesisEnabled(enable);
}
|
CWE-94
| 185,156 | 6,040 |
118835515116955897886468205220110409621
| null | null | null |
Chrome
|
537abce1bcf7378e760e904d6e5540a02a2fca9f
| 1 |
int ShellBrowserMain(const content::MainFunctionParams& parameters) {
bool layout_test_mode =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree);
base::ScopedTempDir browser_context_path_for_layout_tests;
if (layout_test_mode) {
CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());
CHECK(!browser_context_path_for_layout_tests.path().MaybeAsASCII().empty());
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kContentShellDataPath,
browser_context_path_for_layout_tests.path().MaybeAsASCII());
}
scoped_ptr<content::BrowserMainRunner> main_runner_(
content::BrowserMainRunner::Create());
int exit_code = main_runner_->Initialize(parameters);
if (exit_code >= 0)
return exit_code;
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kCheckLayoutTestSysDeps)) {
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
main_runner_->Run();
main_runner_->Shutdown();
return 0;
}
if (layout_test_mode) {
content::WebKitTestController test_controller;
std::string test_string;
CommandLine::StringVector args =
CommandLine::ForCurrentProcess()->GetArgs();
size_t command_line_position = 0;
bool ran_at_least_once = false;
#if defined(OS_ANDROID)
std::cout << "#READY\n";
std::cout.flush();
#endif
while (GetNextTest(args, &command_line_position, &test_string)) {
if (test_string.empty())
continue;
if (test_string == "QUIT")
break;
bool enable_pixel_dumps;
std::string pixel_hash;
FilePath cwd;
GURL test_url = GetURLForLayoutTest(
test_string, &cwd, &enable_pixel_dumps, &pixel_hash);
if (!content::WebKitTestController::Get()->PrepareForLayoutTest(
test_url, cwd, enable_pixel_dumps, pixel_hash)) {
break;
}
ran_at_least_once = true;
main_runner_->Run();
if (!content::WebKitTestController::Get()->ResetAfterLayoutTest())
break;
}
if (!ran_at_least_once) {
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
main_runner_->Run();
}
exit_code = 0;
} else {
exit_code = main_runner_->Run();
}
main_runner_->Shutdown();
return exit_code;
}
|
CWE-200
| 185,167 | 6,050 |
287540519605687564112269399829878507440
| null | null | null |
Chrome
|
70cff275010b33dbab628f837d76364359065b79
| 1 |
void RenderViewImpl::didActivateCompositor(int input_handler_identifier) {
CompositorThread* compositor_thread =
RenderThreadImpl::current()->compositor_thread();
if (compositor_thread)
compositor_thread->AddInputHandler(
routing_id_, input_handler_identifier, AsWeakPtr());
RenderWidget::didActivateCompositor(input_handler_identifier);
ProcessAcceleratedPinchZoomFlags(*CommandLine::ForCurrentProcess());
}
| 185,177 | 6,060 |
185890501714963186996221387722388685318
| null | null | null |
|
Chrome
|
10cbaf017570ba6454174c55b844647aa6a9b3b4
| 1 |
bool ParamTraits<FilePath>::Read(const Message* m,
PickleIterator* iter,
param_type* r) {
FilePath::StringType value;
if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value))
return false;
*r = FilePath(value);
return true;
}
| 185,204 | 6,086 |
149064148065274111848766969539273887849
| null | null | null |
|
Chrome
|
74aaa70032784e7cf00256821f29b2b53edb6589
| 1 |
void ParamTraits<GURL>::Write(Message* m, const GURL& p) {
DCHECK(p.possibly_invalid_spec().length() <= content::kMaxURLChars);
m->WriteString(p.possibly_invalid_spec());
}
|
CWE-264
| 185,206 | 6,087 |
16502622213069891041594794921496030221
| null | null | null |
Chrome
|
935cb0dee7696d70880f96a71bf5687411bb8cb9
| 1 |
bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
DCHECK(!options.executable);
DCHECK(!mapped_file_);
if (options.size == 0)
return false;
uint32 rounded_size = (options.size + 0xffff) & ~0xffff;
name_ = ASCIIToWide(options.name == NULL ? "" : *options.name);
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE, 0, static_cast<DWORD>(rounded_size),
name_.empty() ? NULL : name_.c_str());
if (!mapped_file_)
return false;
created_size_ = options.size;
if (GetLastError() == ERROR_ALREADY_EXISTS) {
created_size_ = 0;
if (!options.open_existing) {
Close();
return false;
}
}
return true;
}
|
CWE-189
| 185,241 | 6,117 |
281356070748747657977759918253453221719
| null | null | null |
Chrome
|
0d7717faeaef5b72434632c95c78bee4883e2573
| 1 |
bool ReturnsValidPath(int dir_type) {
base::FilePath path;
bool result = PathService::Get(dir_type, &path);
bool check_path_exists = true;
#if defined(OS_POSIX)
if (dir_type == base::DIR_CACHE)
check_path_exists = false;
#endif
#if defined(OS_LINUX)
if (dir_type == base::DIR_USER_DESKTOP)
check_path_exists = false;
#endif
#if defined(OS_WIN)
if (dir_type == base::DIR_DEFAULT_USER_QUICK_LAUNCH) {
if (base::win::GetVersion() < base::win::VERSION_VISTA) {
wchar_t default_profile_path[MAX_PATH];
DWORD size = arraysize(default_profile_path);
return (result &&
::GetDefaultUserProfileDirectory(default_profile_path, &size) &&
StartsWith(path.value(), default_profile_path, false));
}
} else if (dir_type == base::DIR_TASKBAR_PINS) {
if (base::win::GetVersion() < base::win::VERSION_WIN7)
check_path_exists = false;
}
#endif
#if defined(OS_MAC)
if (dir_type != base::DIR_EXE && dir_type != base::DIR_MODULE &&
dir_type != base::FILE_EXE && dir_type != base::FILE_MODULE) {
if (path.ReferencesParent())
return false;
}
#else
if (path.ReferencesParent())
return false;
#endif
return result && !path.empty() && (!check_path_exists ||
file_util::PathExists(path));
}
|
CWE-264
| 185,242 | 6,118 |
38994124641422465605189048185799981937
| null | null | null |
Chrome
|
2e02cfe89cbffc8a0bc1bdaee9efe930fd55e376
| 1 |
bool ParamTraits<LOGFONT>::Read(const Message* m, PickleIterator* iter,
param_type* r) {
const char *data;
int data_size = 0;
bool result = m->ReadData(iter, &data, &data_size);
if (result && data_size == sizeof(LOGFONT)) {
memcpy(r, data, sizeof(LOGFONT));
} else {
result = false;
NOTREACHED();
}
return result;
}
|
CWE-20
| 185,291 | 6,161 |
113647827105279359499879937538347908443
| null | null | null |
Chrome
|
8c7c42f5cd3d3cab81fad08b1159106184fa0c47
| 1 |
ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext(
Profile* profile)
: profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_infobar_queue_controller_(
new GeolocationInfoBarQueueController(
base::Bind(
&ChromeGeolocationPermissionContext::NotifyPermissionSet,
this),
profile))) {
}
| 185,292 | 6,162 |
250361441119916363962903299425922961440
| null | null | null |
|
Chrome
|
f7038db6ef172459f14b1b67a5155b8dd210be0f
| 1 |
bool decode(const SharedBuffer& data, bool onlySize)
{
m_decodingSizeOnly = onlySize;
unsigned newByteCount = data.size() - m_bufferLength;
unsigned readOffset = m_bufferLength - m_info.src->bytes_in_buffer;
m_info.src->bytes_in_buffer += newByteCount;
m_info.src->next_input_byte = (JOCTET*)(data.data()) + readOffset;
if (m_bytesToSkip)
skipBytes(m_bytesToSkip);
m_bufferLength = data.size();
if (setjmp(m_err.setjmp_buffer))
return m_decoder->setFailed();
switch (m_state) {
case JPEG_HEADER:
if (jpeg_read_header(&m_info, true) == JPEG_SUSPENDED)
return false; // I/O suspension.
switch (m_info.jpeg_color_space) {
case JCS_GRAYSCALE:
case JCS_RGB:
case JCS_YCbCr:
m_info.out_color_space = rgbOutputColorSpace();
#if defined(TURBO_JPEG_RGB_SWIZZLE)
if (m_info.saw_JFIF_marker)
break;
if (m_info.saw_Adobe_marker && !m_info.Adobe_transform)
m_info.out_color_space = JCS_RGB;
#endif
break;
case JCS_CMYK:
case JCS_YCCK:
m_info.out_color_space = JCS_CMYK;
break;
default:
return m_decoder->setFailed();
}
m_state = JPEG_START_DECOMPRESS;
if (!m_decoder->setSize(m_info.image_width, m_info.image_height))
return false;
m_decoder->setOrientation(readImageOrientation(info()));
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
if (m_decoder->willDownSample() && turboSwizzled(m_info.out_color_space))
m_info.out_color_space = JCS_RGB;
#endif
#if USE(QCMSLIB)
if (!m_decoder->ignoresGammaAndColorProfile()) {
ColorProfile colorProfile = readColorProfile(info());
createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
#if defined(TURBO_JPEG_RGB_SWIZZLE)
if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
m_info.out_color_space = JCS_EXT_RGBA;
#endif
}
#endif
m_info.buffered_image = jpeg_has_multiple_scans(&m_info);
jpeg_calc_output_dimensions(&m_info);
m_samples = (*m_info.mem->alloc_sarray)((j_common_ptr) &m_info, JPOOL_IMAGE, m_info.output_width * 4, 1);
if (m_decodingSizeOnly) {
m_bufferLength -= m_info.src->bytes_in_buffer;
m_info.src->bytes_in_buffer = 0;
return true;
}
case JPEG_START_DECOMPRESS:
m_info.dct_method = dctMethod();
m_info.dither_mode = ditherMode();
m_info.do_fancy_upsampling = doFancyUpsampling();
m_info.enable_2pass_quant = false;
m_info.do_block_smoothing = true;
if (!jpeg_start_decompress(&m_info))
return false; // I/O suspension.
m_state = (m_info.buffered_image) ? JPEG_DECOMPRESS_PROGRESSIVE : JPEG_DECOMPRESS_SEQUENTIAL;
case JPEG_DECOMPRESS_SEQUENTIAL:
if (m_state == JPEG_DECOMPRESS_SEQUENTIAL) {
if (!m_decoder->outputScanlines())
return false; // I/O suspension.
ASSERT(m_info.output_scanline == m_info.output_height);
m_state = JPEG_DONE;
}
case JPEG_DECOMPRESS_PROGRESSIVE:
if (m_state == JPEG_DECOMPRESS_PROGRESSIVE) {
int status;
do {
status = jpeg_consume_input(&m_info);
} while ((status != JPEG_SUSPENDED) && (status != JPEG_REACHED_EOI));
for (;;) {
if (!m_info.output_scanline) {
int scan = m_info.input_scan_number;
if (!m_info.output_scan_number && (scan > 1) && (status != JPEG_REACHED_EOI))
--scan;
if (!jpeg_start_output(&m_info, scan))
return false; // I/O suspension.
}
if (m_info.output_scanline == 0xffffff)
m_info.output_scanline = 0;
if (!m_decoder->outputScanlines()) {
if (!m_info.output_scanline)
m_info.output_scanline = 0xffffff;
return false; // I/O suspension.
}
if (m_info.output_scanline == m_info.output_height) {
if (!jpeg_finish_output(&m_info))
return false; // I/O suspension.
if (jpeg_input_complete(&m_info) && (m_info.input_scan_number == m_info.output_scan_number))
break;
m_info.output_scanline = 0;
}
}
m_state = JPEG_DONE;
}
case JPEG_DONE:
return jpeg_finish_decompress(&m_info);
case JPEG_ERROR:
return m_decoder->setFailed();
}
return true;
}
|
CWE-399
| 185,293 | 6,163 |
163182612046974403737963361994360222030
| null | null | null |
Chrome
|
d333e22282bd4bdaa2864980cd45c272f206a44c
| 1 |
void LayerWebKitThread::setNeedsCommit()
{
if (m_owner)
m_owner->notifySyncRequired();
}
|
CWE-20
| 185,294 | 6,164 |
74204523172678715611232918460424691981
| null | null | null |
Chrome
|
9965adea952e84c925de418e971b204dfda7d6e0
| 1 |
int MockNetworkTransaction::RestartWithAuth(
const AuthCredentials& credentials,
const CompletionCallback& callback) {
if (!IsReadyToRestartForAuth())
return ERR_FAILED;
HttpRequestInfo auth_request_info = *request_;
auth_request_info.extra_headers.AddHeaderFromString("Authorization: Bar");
return StartInternal(&auth_request_info, callback, BoundNetLog());
}
|
CWE-119
| 185,304 | 6,173 |
264094544930396230310436479757497141483
| null | null | null |
Chrome
|
2571533bbb5b554ff47205c8ef1513ccc0817c3e
| 1 |
void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, ResourceLoaderOptions resourceLoaderOptions)
{
const KURL& requestURL = request.url();
ASSERT(m_sameOriginRequest || requestURL.user().isEmpty());
ASSERT(m_sameOriginRequest || requestURL.pass().isEmpty());
if (m_forceDoNotAllowStoredCredentials)
resourceLoaderOptions.allowCredentials = DoNotAllowStoredCredentials;
resourceLoaderOptions.securityOrigin = m_securityOrigin;
if (m_async) {
if (!m_actualRequest.isNull())
resourceLoaderOptions.dataBufferingPolicy = BufferData;
if (m_options.timeoutMilliseconds > 0)
m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE);
FetchRequest newRequest(request, m_options.initiator, resourceLoaderOptions);
if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
ASSERT(!resource());
if (request.requestContext() == WebURLRequest::RequestContextVideo || request.requestContext() == WebURLRequest::RequestContextAudio)
setResource(RawResource::fetchMedia(newRequest, document().fetcher()));
else if (request.requestContext() == WebURLRequest::RequestContextManifest)
setResource(RawResource::fetchManifest(newRequest, document().fetcher()));
else
setResource(RawResource::fetch(newRequest, document().fetcher()));
if (!resource()) {
InspectorInstrumentation::documentThreadableLoaderFailedToStartLoadingForClient(m_document, m_client);
ThreadableLoaderClient* client = m_client;
clear();
client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestURL.getString(), "Failed to start loading."));
return;
}
if (resource()->loader()) {
unsigned long identifier = resource()->identifier();
InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_document, identifier, m_client);
} else {
InspectorInstrumentation::documentThreadableLoaderFailedToStartLoadingForClient(m_document, m_client);
}
return;
}
FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOptions);
if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
Resource* resource = RawResource::fetchSynchronously(fetchRequest, document().fetcher());
ResourceResponse response = resource ? resource->response() : ResourceResponse();
unsigned long identifier = resource ? resource->identifier() : std::numeric_limits<unsigned long>::max();
ResourceError error = resource ? resource->resourceError() : ResourceError();
InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_document, identifier, m_client);
if (!resource) {
m_client->didFail(error);
return;
}
if (!error.isNull() && !requestURL.isLocalFile() && response.httpStatusCode() <= 0) {
m_client->didFail(error);
return;
}
if (requestURL != response.url() && !isAllowedRedirect(response.url())) {
m_client->didFailRedirectCheck();
return;
}
handleResponse(identifier, response, nullptr);
if (!m_client)
return;
SharedBuffer* data = resource->resourceBuffer();
if (data)
handleReceivedData(data->data(), data->size());
if (!m_client)
return;
handleSuccessfulFinish(identifier, 0.0);
}
|
CWE-189
| 185,315 | 6,182 |
318306592559316865388544224660320461566
| null | null | null |
Chrome
|
11a4cc4a6d6e665d9a118fada4b7c658d6f70d95
| 1 |
void FrameView::updateLayoutAndStyleForPainting()
{
RefPtr<FrameView> protector(this);
updateLayoutAndStyleIfNeededRecursive();
if (RenderView* view = renderView()) {
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateLayerTree", "frame", m_frame.get());
InspectorInstrumentation::willUpdateLayerTree(m_frame.get());
view->compositor()->updateIfNeededRecursive();
if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot())
m_frame->page()->scrollingCoordinator()->updateAfterCompositingChangeIfNeeded();
updateCompositedSelectionBoundsIfNeeded();
InspectorInstrumentation::didUpdateLayerTree(m_frame.get());
invalidateTreeIfNeededRecursive();
}
scrollContentsIfNeededRecursive();
ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
}
|
CWE-416
| 185,339 | 6,201 |
145960508048872618597919539860563038311
| null | null | null |
Chrome
|
11a4cc4a6d6e665d9a118fada4b7c658d6f70d95
| 1 |
void RenderLayerScrollableArea::setScrollOffset(const IntPoint& newScrollOffset)
{
if (!box().isMarquee()) {
if (m_scrollDimensionsDirty)
computeScrollDimensions();
}
if (scrollOffset() == toIntSize(newScrollOffset))
return;
setScrollOffset(toIntSize(newScrollOffset));
LocalFrame* frame = box().frame();
ASSERT(frame);
RefPtr<FrameView> frameView = box().frameView();
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ScrollLayer", "data", InspectorScrollLayerEvent::data(&box()));
InspectorInstrumentation::willScrollLayer(&box());
const RenderLayerModelObject* paintInvalidationContainer = box().containerForPaintInvalidation();
if (!frameView->isInPerformLayout()) {
layer()->clipper().clearClipRectsIncludingDescendants();
box().setPreviousPaintInvalidationRect(box().boundsRectForPaintInvalidation(paintInvalidationContainer));
frameView->updateAnnotatedRegions();
frameView->updateWidgetPositions();
RELEASE_ASSERT(frameView->renderView());
updateCompositingLayersAfterScroll();
}
frame->selection().setCaretRectNeedsUpdate();
FloatQuad quadForFakeMouseMoveEvent = FloatQuad(layer()->renderer()->previousPaintInvalidationRect());
quadForFakeMouseMoveEvent = paintInvalidationContainer->localToAbsoluteQuad(quadForFakeMouseMoveEvent);
frame->eventHandler().dispatchFakeMouseMoveEventSoonInQuad(quadForFakeMouseMoveEvent);
bool requiresPaintInvalidation = true;
if (!box().isMarquee() && box().view()->compositor()->inCompositingMode()) {
DisableCompositingQueryAsserts disabler;
bool onlyScrolledCompositedLayers = scrollsOverflow()
&& !layer()->hasVisibleNonLayerContent()
&& !layer()->hasNonCompositedChild()
&& !layer()->hasBlockSelectionGapBounds()
&& box().style()->backgroundLayers().attachment() != LocalBackgroundAttachment;
if (usesCompositedScrolling() || onlyScrolledCompositedLayers)
requiresPaintInvalidation = false;
}
if (requiresPaintInvalidation) {
if (box().frameView()->isInPerformLayout())
box().setShouldDoFullPaintInvalidation(true);
else
box().invalidatePaintUsingContainer(paintInvalidationContainer, layer()->renderer()->previousPaintInvalidationRect(), InvalidationScroll);
}
if (box().node())
box().node()->document().enqueueScrollEventForNode(box().node());
if (AXObjectCache* cache = box().document().existingAXObjectCache())
cache->handleScrollPositionChanged(&box());
InspectorInstrumentation::didScrollLayer(&box());
}
|
CWE-416
| 185,340 | 6,202 |
288520017721751269794255910549441206362
| null | null | null |
Chrome
|
9b04ffd8e7a07e9b2947fe5b71acf85dff38a63f
| 1 |
bool Instance::HandleInputEvent(const pp::InputEvent& event) {
pp::InputEvent event_device_res(event);
{
pp::MouseInputEvent mouse_event(event);
if (!mouse_event.is_null()) {
pp::Point point = mouse_event.GetPosition();
pp::Point movement = mouse_event.GetMovement();
ScalePoint(device_scale_, &point);
ScalePoint(device_scale_, &movement);
mouse_event = pp::MouseInputEvent(
this,
event.GetType(),
event.GetTimeStamp(),
event.GetModifiers(),
mouse_event.GetButton(),
point,
mouse_event.GetClickCount(),
movement);
event_device_res = mouse_event;
}
}
if (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE &&
(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN)) {
pp::MouseInputEvent mouse_event(event_device_res);
pp::Point pos = mouse_event.GetPosition();
EnableAutoscroll(pos);
UpdateCursor(CalculateAutoscroll(pos));
return true;
} else {
DisableAutoscroll();
}
#ifdef ENABLE_THUMBNAILS
if (event.GetType() == PP_INPUTEVENT_TYPE_MOUSELEAVE)
thumbnails_.SlideOut();
if (thumbnails_.HandleEvent(event_device_res))
return true;
#endif
if (toolbar_->HandleEvent(event_device_res))
return true;
#ifdef ENABLE_THUMBNAILS
if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE) {
pp::MouseInputEvent mouse_event(event);
pp::Point pt = mouse_event.GetPosition();
pp::Rect v_scrollbar_rc;
v_scrollbar_->GetLocation(&v_scrollbar_rc);
if (v_scrollbar_rc.Contains(pt) &&
(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN)) {
thumbnails_.SlideIn();
}
if (!v_scrollbar_rc.Contains(pt) && thumbnails_.visible() &&
!(event.GetModifiers() & PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN) &&
!thumbnails_.rect().Contains(pt)) {
thumbnails_.SlideOut();
}
}
#endif
pp::InputEvent offset_event(event_device_res);
bool try_engine_first = true;
switch (offset_event.GetType()) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
case PP_INPUTEVENT_TYPE_MOUSEUP:
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
case PP_INPUTEVENT_TYPE_MOUSEENTER:
case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
pp::MouseInputEvent mouse_event(event_device_res);
pp::MouseInputEvent mouse_event_dip(event);
pp::Point point = mouse_event.GetPosition();
point.set_x(point.x() - available_area_.x());
offset_event = pp::MouseInputEvent(
this,
event.GetType(),
event.GetTimeStamp(),
event.GetModifiers(),
mouse_event.GetButton(),
point,
mouse_event.GetClickCount(),
mouse_event.GetMovement());
if (!engine_->IsSelecting()) {
if (!IsOverlayScrollbar() &&
!available_area_.Contains(mouse_event.GetPosition())) {
try_engine_first = false;
} else if (IsOverlayScrollbar()) {
pp::Rect temp;
if ((v_scrollbar_.get() && v_scrollbar_->GetLocation(&temp) &&
temp.Contains(mouse_event_dip.GetPosition())) ||
(h_scrollbar_.get() && h_scrollbar_->GetLocation(&temp) &&
temp.Contains(mouse_event_dip.GetPosition()))) {
try_engine_first = false;
}
}
}
break;
}
default:
break;
}
if (try_engine_first && engine_->HandleEvent(offset_event))
return true;
if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) {
pp::KeyboardInputEvent keyboard_event(event);
bool no_h_scrollbar = !h_scrollbar_.get();
uint32_t key_code = keyboard_event.GetKeyCode();
bool page_down = no_h_scrollbar && key_code == ui::VKEY_RIGHT;
bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT;
if (zoom_mode_ == ZOOM_FIT_TO_PAGE) {
bool has_shift =
keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY;
bool key_is_space = key_code == ui::VKEY_SPACE;
page_down |= key_is_space || key_code == ui::VKEY_NEXT;
page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR);
}
if (page_down) {
int page = engine_->GetFirstVisiblePage();
if (engine_->GetPageRect(page).bottom() * zoom_ <=
v_scrollbar_->GetValue())
page++;
ScrollToPage(page + 1);
UpdateCursor(PP_CURSORTYPE_POINTER);
return true;
} else if (page_up) {
int page = engine_->GetFirstVisiblePage();
if (engine_->GetPageRect(page).y() * zoom_ >= v_scrollbar_->GetValue())
page--;
ScrollToPage(page);
UpdateCursor(PP_CURSORTYPE_POINTER);
return true;
}
}
if (v_scrollbar_.get() && v_scrollbar_->HandleEvent(event)) {
UpdateCursor(PP_CURSORTYPE_POINTER);
return true;
}
if (h_scrollbar_.get() && h_scrollbar_->HandleEvent(event)) {
UpdateCursor(PP_CURSORTYPE_POINTER);
return true;
}
if (timer_pending_ &&
(event.GetType() == PP_INPUTEVENT_TYPE_MOUSEUP ||
event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE)) {
timer_factory_.CancelAll();
timer_pending_ = false;
} else if (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE &&
engine_->IsSelecting()) {
bool set_timer = false;
pp::MouseInputEvent mouse_event(event);
if (v_scrollbar_.get() &&
(mouse_event.GetPosition().y() <= 0 ||
mouse_event.GetPosition().y() >= (plugin_dip_size_.height() - 1))) {
v_scrollbar_->ScrollBy(
PP_SCROLLBY_LINE, mouse_event.GetPosition().y() >= 0 ? 1: -1);
set_timer = true;
}
if (h_scrollbar_.get() &&
(mouse_event.GetPosition().x() <= 0 ||
mouse_event.GetPosition().x() >= (plugin_dip_size_.width() - 1))) {
h_scrollbar_->ScrollBy(PP_SCROLLBY_LINE,
mouse_event.GetPosition().x() >= 0 ? 1: -1);
set_timer = true;
}
if (set_timer) {
last_mouse_event_ = pp::MouseInputEvent(event);
pp::CompletionCallback callback =
timer_factory_.NewCallback(&Instance::OnTimerFired);
pp::Module::Get()->core()->CallOnMainThread(kDragTimerMs, callback);
timer_pending_ = true;
}
}
if (event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN &&
event.GetModifiers() & kDefaultKeyModifier) {
pp::KeyboardInputEvent keyboard_event(event);
switch (keyboard_event.GetKeyCode()) {
case 'A':
engine_->SelectAll();
return true;
}
}
return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN);
}
|
CWE-119
| 185,343 | 6,205 |
2949400329031433599365771668374079693
| null | null | null |
Chrome
|
2f663de43634c1197a7a2ed8afc12cb6dc565bd0
| 1 |
void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
if (!context_)
return;
scoped_refptr<gfx::GLContext> previous_context = gfx::GLContext::GetCurrent();
scoped_refptr<gfx::GLSurface> previous_surface;
bool was_current = previous_context && previous_context->IsCurrent(nullptr) &&
gfx::GLSurface::GetCurrent() == this;
if (!was_current) {
previous_surface = gfx::GLSurface::GetCurrent();
context_->MakeCurrent(this);
}
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
if (fbo_) {
glDeleteTextures(arraysize(textures_), textures_);
for (auto& texture : textures_)
texture = 0;
glDeleteFramebuffersEXT(1, &fbo_);
fbo_ = 0;
}
for (auto image : images_) {
if (image)
image->Destroy(true);
}
if (!was_current) {
previous_context->MakeCurrent(previous_surface.get());
} else {
context_->ReleaseCurrent(this);
}
}
| 185,352 | 6,214 |
338280291374188398925731245396554185547
| null | null | null |
|
Chrome
|
f592cf6a66b63decc7e7093b36501229a5de1f1d
| 1 |
void SVGDocumentExtensions::startAnimations()
{
WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement> > timeContainers;
timeContainers.appendRange(m_timeContainers.begin(), m_timeContainers.end());
WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement> >::iterator end = timeContainers.end();
for (WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement> >::iterator itr = timeContainers.begin(); itr != end; ++itr)
(*itr)->timeContainer()->begin();
}
| 185,353 | 6,215 |
337365604826060539328300041419096862359
| null | null | null |
|
Chrome
|
4843d98517bd37e5940cd04627c6cfd2ac774d11
| 1 |
void CorePageLoadMetricsObserver::RecordTimingHistograms(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& info) {
if (info.started_in_foreground && info.first_background_time) {
const base::TimeDelta first_background_time =
info.first_background_time.value();
if (!info.time_to_commit) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundBeforeCommit,
first_background_time);
} else if (!timing.first_paint ||
timing.first_paint > first_background_time) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundBeforePaint,
first_background_time);
}
if (timing.parse_start && first_background_time >= timing.parse_start &&
(!timing.parse_stop || timing.parse_stop > first_background_time)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundDuringParse,
first_background_time);
}
}
if (failed_provisional_load_info_.error != net::OK) {
DCHECK(failed_provisional_load_info_.interval);
if (WasStartedInForegroundOptionalEventInForeground(
failed_provisional_load_info_.interval, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFailedProvisionalLoad,
failed_provisional_load_info_.interval.value());
}
}
if (!info.time_to_commit || timing.IsEmpty())
return;
const base::TimeDelta time_to_commit = info.time_to_commit.value();
if (WasStartedInForegroundOptionalEventInForeground(info.time_to_commit,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramCommit, time_to_commit);
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramCommit, time_to_commit);
}
if (timing.dom_content_loaded_event_start) {
if (WasStartedInForegroundOptionalEventInForeground(
timing.dom_content_loaded_event_start, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramDomContentLoaded,
timing.dom_content_loaded_event_start.value());
PAGE_LOAD_HISTOGRAM(internal::kHistogramDomLoadingToDomContentLoaded,
timing.dom_content_loaded_event_start.value() -
timing.dom_loading.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramDomContentLoaded,
timing.dom_content_loaded_event_start.value());
}
}
if (timing.load_event_start) {
if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLoad,
timing.load_event_start.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramLoad,
timing.load_event_start.value());
}
}
if (timing.first_layout) {
if (WasStartedInForegroundOptionalEventInForeground(timing.first_layout,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstLayout,
timing.first_layout.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstLayout,
timing.first_layout.value());
}
}
if (timing.first_paint) {
if (WasStartedInForegroundOptionalEventInForeground(timing.first_paint,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstPaint,
timing.first_paint.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstPaint,
timing.first_paint.value());
}
if (!info.started_in_foreground && info.first_foreground_time &&
timing.first_paint > info.first_foreground_time.value() &&
(!info.first_background_time ||
timing.first_paint < info.first_background_time.value())) {
PAGE_LOAD_HISTOGRAM(
internal::kHistogramForegroundToFirstPaint,
timing.first_paint.value() - info.first_foreground_time.value());
}
}
if (timing.first_text_paint) {
if (WasStartedInForegroundOptionalEventInForeground(timing.first_text_paint,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstTextPaint,
timing.first_text_paint.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstTextPaint,
timing.first_text_paint.value());
}
}
if (timing.first_image_paint) {
if (WasStartedInForegroundOptionalEventInForeground(
timing.first_image_paint, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstImagePaint,
timing.first_image_paint.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstImagePaint,
timing.first_image_paint.value());
}
}
if (timing.first_contentful_paint) {
if (WasStartedInForegroundOptionalEventInForeground(
timing.first_contentful_paint, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaint,
timing.first_contentful_paint.value());
if (base::TimeTicks::IsHighResolution()) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintHigh,
timing.first_contentful_paint.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaintLow,
timing.first_contentful_paint.value());
}
PAGE_LOAD_HISTOGRAM(
internal::kHistogramParseStartToFirstContentfulPaint,
timing.first_contentful_paint.value() - timing.parse_start.value());
PAGE_LOAD_HISTOGRAM(
internal::kHistogramDomLoadingToFirstContentfulPaint,
timing.first_contentful_paint.value() - timing.dom_loading.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstContentfulPaint,
timing.first_contentful_paint.value());
}
}
if (timing.parse_start) {
if (WasParseInForeground(timing.parse_start, timing.parse_stop, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramParseBlockedOnScriptLoad,
timing.parse_blocked_on_script_load_duration.value());
PAGE_LOAD_HISTOGRAM(
internal::kHistogramParseBlockedOnScriptLoadDocumentWrite,
timing.parse_blocked_on_script_load_from_document_write_duration
.value());
} else {
PAGE_LOAD_HISTOGRAM(
internal::kBackgroundHistogramParseBlockedOnScriptLoad,
timing.parse_blocked_on_script_load_duration.value());
PAGE_LOAD_HISTOGRAM(
internal::kBackgroundHistogramParseBlockedOnScriptLoadDocumentWrite,
timing.parse_blocked_on_script_load_from_document_write_duration
.value());
}
}
if (timing.parse_stop) {
base::TimeDelta parse_duration =
timing.parse_stop.value() - timing.parse_start.value();
if (WasStartedInForegroundOptionalEventInForeground(timing.parse_stop,
info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramParseDuration, parse_duration);
PAGE_LOAD_HISTOGRAM(
internal::kHistogramParseBlockedOnScriptLoadParseComplete,
timing.parse_blocked_on_script_load_duration.value());
PAGE_LOAD_HISTOGRAM(
internal::
kHistogramParseBlockedOnScriptLoadDocumentWriteParseComplete,
timing.parse_blocked_on_script_load_from_document_write_duration
.value());
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramParseDuration,
parse_duration);
PAGE_LOAD_HISTOGRAM(
internal::kBackgroundHistogramParseBlockedOnScriptLoadParseComplete,
timing.parse_blocked_on_script_load_duration.value());
PAGE_LOAD_HISTOGRAM(
internal::
kBackgroundHistogramParseBlockedOnScriptLoadDocumentWriteParseComplete,
timing.parse_blocked_on_script_load_from_document_write_duration
.value());
}
}
if (info.started_in_foreground) {
if (info.first_background_time)
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstBackground,
info.first_background_time.value());
} else {
if (info.first_foreground_time)
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground,
info.first_foreground_time.value());
}
}
| 185,367 | 6,228 |
203987373529770784253455580771271360830
| null | null | null |
|
Chrome
|
ee281f7cac9df44fe241a37f188b28be8845ded0
| 1 |
bool ResourceFetcher::canRequest(Resource::Type type, const KURL& url, const ResourceLoaderOptions& options, bool forPreload, FetchRequest::OriginRestriction originRestriction) const
{
SecurityOrigin* securityOrigin = options.securityOrigin.get();
if (!securityOrigin && document())
securityOrigin = document()->securityOrigin();
if (securityOrigin && !securityOrigin->canDisplay(url)) {
if (!forPreload)
context().reportLocalLoadFailed(url);
WTF_LOG(ResourceLoading, "ResourceFetcher::requestResource URL was not allowed by SecurityOrigin::canDisplay");
return 0;
}
bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy()) || (options.contentSecurityPolicyOption == DoNotCheckContentSecurityPolicy);
switch (type) {
case Resource::MainResource:
case Resource::Image:
case Resource::CSSStyleSheet:
case Resource::Script:
case Resource::Font:
case Resource::Raw:
case Resource::LinkPrefetch:
case Resource::LinkSubresource:
case Resource::TextTrack:
case Resource::ImportResource:
case Resource::Media:
if (originRestriction == FetchRequest::RestrictToSameOrigin && !securityOrigin->canRequest(url)) {
printAccessDeniedMessage(url);
return false;
}
break;
case Resource::XSLStyleSheet:
ASSERT(RuntimeEnabledFeatures::xsltEnabled());
case Resource::SVGDocument:
if (!securityOrigin->canRequest(url)) {
printAccessDeniedMessage(url);
return false;
}
break;
}
ContentSecurityPolicy::ReportingStatus cspReporting = forPreload ?
ContentSecurityPolicy::SuppressReport : ContentSecurityPolicy::SendReport;
switch (type) {
case Resource::XSLStyleSheet:
ASSERT(RuntimeEnabledFeatures::xsltEnabled());
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url, cspReporting))
return false;
break;
case Resource::Script:
case Resource::ImportResource:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowScriptFromSource(url, cspReporting))
return false;
if (frame()) {
Settings* settings = frame()->settings();
if (!frame()->loader().client()->allowScriptFromSource(!settings || settings->scriptEnabled(), url)) {
frame()->loader().client()->didNotAllowScript();
return false;
}
}
break;
case Resource::CSSStyleSheet:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowStyleFromSource(url, cspReporting))
return false;
break;
case Resource::SVGDocument:
case Resource::Image:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowImageFromSource(url, cspReporting))
return false;
break;
case Resource::Font: {
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowFontFromSource(url, cspReporting))
return false;
break;
}
case Resource::MainResource:
case Resource::Raw:
case Resource::LinkPrefetch:
case Resource::LinkSubresource:
break;
case Resource::Media:
case Resource::TextTrack:
if (!shouldBypassMainWorldContentSecurityPolicy && !m_document->contentSecurityPolicy()->allowMediaFromSource(url, cspReporting))
return false;
break;
}
if (!checkInsecureContent(type, url, options.mixedContentBlockingTreatment))
return false;
return true;
}
|
CWE-264
| 185,375 | 6,234 |
171053594726445858943061543003045321901
| null | null | null |
Chrome
|
f14efc560a12a513696d6396413b138879dabd7a
| 1 |
void ChildThread::Shutdown() {
file_system_dispatcher_.reset();
quota_dispatcher_.reset();
}
| 185,376 | 6,235 |
339551621348072306137421313917405062946
| null | null | null |
|
Chrome
|
96e8ffb4e805c7266a2fc1fbe0e470052019bad9
| 1 |
int FFmpegVideoDecoder::GetVideoBuffer(AVCodecContext* codec_context,
AVFrame* frame) {
VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt);
if (format == VideoFrame::UNKNOWN)
return AVERROR(EINVAL);
DCHECK(format == VideoFrame::YV12 || format == VideoFrame::YV16 ||
format == VideoFrame::YV12J);
gfx::Size size(codec_context->width, codec_context->height);
int ret;
if ((ret = av_image_check_size(size.width(), size.height(), 0, NULL)) < 0)
return ret;
gfx::Size natural_size;
if (codec_context->sample_aspect_ratio.num > 0) {
natural_size = GetNaturalSize(size,
codec_context->sample_aspect_ratio.num,
codec_context->sample_aspect_ratio.den);
} else {
natural_size = config_.natural_size();
}
if (!VideoFrame::IsValidConfig(format, size, gfx::Rect(size), natural_size))
return AVERROR(EINVAL);
scoped_refptr<VideoFrame> video_frame =
frame_pool_.CreateFrame(format, size, gfx::Rect(size),
natural_size, kNoTimestamp());
for (int i = 0; i < 3; i++) {
frame->base[i] = video_frame->data(i);
frame->data[i] = video_frame->data(i);
frame->linesize[i] = video_frame->stride(i);
}
frame->opaque = NULL;
video_frame.swap(reinterpret_cast<VideoFrame**>(&frame->opaque));
frame->type = FF_BUFFER_TYPE_USER;
frame->width = codec_context->width;
frame->height = codec_context->height;
frame->format = codec_context->pix_fmt;
return 0;
}
|
CWE-119
| 185,381 | 6,239 |
37770097475656599506993054524710622776
| null | null | null |
Chrome
|
d22bd7ecd1cc576a1a586ee59d5e08d7eee6cdf3
| 1 |
Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint->inDocument()) {
Element* ownerElement = document().ownerElement();
if (isHTMLFrameElementBase(ownerElement)) {
HTMLFrameElementBase& ownerFrameElement = toHTMLFrameElementBase(*ownerElement);
int marginWidth = ownerFrameElement.marginWidth();
if (marginWidth != -1)
setIntegralAttribute(marginwidthAttr, marginWidth);
int marginHeight = ownerFrameElement.marginHeight();
if (marginHeight != -1)
setIntegralAttribute(marginheightAttr, marginHeight);
}
}
return InsertionDone;
}
| 185,426 | 6,278 |
300310424537321855592534382829736434019
| null | null | null |
|
Chrome
|
31b2ef216cb19fb5cec60eb507d3b2b0d30cd648
| 1 |
MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
AddSettingsPageUIHandler(new AppearanceHandler(web_ui));
AddSettingsPageUIHandler(new DownloadsHandler());
AddSettingsPageUIHandler(new StartupPagesHandler(web_ui));
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost);
for (size_t i = 0; i < kSettingsResourcesSize; ++i) {
html_source->AddResourcePath(kSettingsResources[i].name,
kSettingsResources[i].value);
}
AddLocalizedStrings(html_source);
html_source->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
html_source);
}
| 185,427 | 6,279 |
14428105432146443195582911225327757961
| null | null | null |
|
Chrome
|
da9a32b9e282c1653bb6b5c1b8c89a1970905f21
| 1 |
bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
if (delegate_->OnMessageReceived(this, msg))
return true;
if (cross_process_frame_connector_ &&
cross_process_frame_connector_->OnMessageReceived(msg))
return true;
bool handled = true;
bool msg_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok)
IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach)
IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame,
OnDidStartProvisionalLoadForFrame)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError,
OnDidFailProvisionalLoadWithError)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad,
OnDidRedirectProvisionalLoad)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError,
OnDidFailLoadWithError)
IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
OnNavigate(msg))
IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading)
IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL)
IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK)
IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse,
OnJavaScriptExecuteResponse)
IPC_END_MESSAGE_MAP_EX()
if (!msg_is_ok) {
RecordAction(base::UserMetricsAction("BadMessageTerminate_RFH"));
GetProcess()->ReceivedBadMessage();
}
return handled;
}
| 185,428 | 6,280 |
81461779803334313673802225872873919464
| null | null | null |
|
Chrome
|
91b27188b728e90c651c55a985d23ad0c26eb662
| 1 |
static inline bool base64DecodeInternal(const T* data, unsigned length, Vector<char>& out, CharacterMatchFunctionPtr shouldIgnoreCharacter, Base64DecodePolicy policy)
{
out.clear();
if (!length)
return true;
out.grow(length);
unsigned equalsSignCount = 0;
unsigned outLength = 0;
for (unsigned idx = 0; idx < length; ++idx) {
unsigned ch = data[idx];
if (ch == '=') {
++equalsSignCount;
if (policy == Base64ValidatePadding && equalsSignCount > 2)
return false;
} else if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ch == '+' || ch == '/') {
if (equalsSignCount)
return false;
out[outLength++] = base64DecMap[ch];
} else if (!shouldIgnoreCharacter || !shouldIgnoreCharacter(ch)) {
return false;
}
}
if (!outLength)
return !equalsSignCount;
if (policy == Base64ValidatePadding && equalsSignCount && (outLength + equalsSignCount) % 4)
return false;
if ((outLength % 4) == 1)
return false;
outLength -= (outLength + 3) / 4;
if (!outLength)
return false;
unsigned sidx = 0;
unsigned didx = 0;
if (outLength > 1) {
while (didx < outLength - 2) {
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx + 1] >> 4) & 003));
out[didx + 1] = (((out[sidx + 1] << 4) & 255) | ((out[sidx + 2] >> 2) & 017));
out[didx + 2] = (((out[sidx + 2] << 6) & 255) | (out[sidx + 3] & 077));
sidx += 4;
didx += 3;
}
}
if (didx < outLength)
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx + 1] >> 4) & 003));
if (++didx < outLength)
out[didx] = (((out[sidx + 1] << 4) & 255) | ((out[sidx + 2] >> 2) & 017));
if (outLength < out.size())
out.shrink(outLength);
return true;
}
| 185,429 | 6,281 |
172328834144020677789191072960162381361
| null | null | null |
|
Chrome
|
9ad7483d8e7c20e9f1a5a08d00150fb51899f14c
| 1 |
void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) {
DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
DCHECK(!shutdown_watchdog_);
base::TimeDelta actual_duration = duration;
version_info::Channel channel = chrome::GetChannel();
if (channel == version_info::Channel::STABLE) {
actual_duration *= 20;
} else if (channel == version_info::Channel::BETA ||
channel == version_info::Channel::DEV) {
actual_duration *= 10;
}
#if defined(OS_WIN)
if (base::win::GetVersion() <= base::win::VERSION_XP)
actual_duration *= 2;
#endif
shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration);
shutdown_watchdog_->Arm();
}
| 185,452 | 6,303 |
159659471025236588378409697187150106881
| null | null | null |
|
Chrome
|
b71fc042e1124cda2ab51dfdacc2362da62779a6
| 1 |
bool AsyncPixelTransfersCompletedQuery::End(
base::subtle::Atomic32 submit_count) {
AsyncMemoryParams mem_params;
Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id());
if (!buffer.shared_memory)
return false;
mem_params.shared_memory = buffer.shared_memory;
mem_params.shm_size = buffer.size;
mem_params.shm_data_offset = shm_offset();
mem_params.shm_data_size = sizeof(QuerySync);
observer_ = new AsyncPixelTransferCompletionObserverImpl(submit_count);
manager()->decoder()->GetAsyncPixelTransferManager()
->AsyncNotifyCompletion(mem_params, observer_);
return AddToPendingTransferQueue(submit_count);
}
|
CWE-119
| 185,457 | 6,308 |
17389564410575506245043280837766861616
| null | null | null |
Chrome
|
318530d771586b39056c0da7b8bdad03469a0dc4
| 1 |
bool IsSmartVirtualKeyboardEnabled() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
keyboard::switches::kEnableVirtualKeyboard)) {
return false;
}
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
keyboard::switches::kDisableSmartVirtualKeyboard);
}
|
CWE-399
| 185,478 | 6,328 |
138519658245803257847370065027879623446
| null | null | null |
Chrome
|
70bcb6b3396a395e871e10b2ff883d92b8218e9f
| 1 |
void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
{
ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
return;
FloatRect boundingBox = repaintRectInLocalCoordinates();
if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTransform, paintInfo))
return;
PaintInfo childPaintInfo(paintInfo);
bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline);
if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) {
GraphicsContextStateSaver stateSaver(*childPaintInfo.context);
childPaintInfo.applyTransform(m_localTransform);
if (childPaintInfo.phase == PaintPhaseForeground) {
SVGRenderingContext renderingContext(this, childPaintInfo);
if (renderingContext.isRenderingPrepared()) {
if (style()->svgStyle()->bufferedRendering() == BR_STATIC && renderingContext.bufferForeground(m_bufferedForeground))
return;
paintForeground(childPaintInfo);
}
}
if (drawsOutline)
paintOutline(childPaintInfo, IntRect(boundingBox));
}
}
|
CWE-399
| 185,504 | 6,350 |
78156417942089071426915516898743240603
| null | null | null |
Chrome
|
cace1e6998293b9b025d4bbdaf5cb5b6a1c2efb4
| 1 |
void SVGImage::setContainerSize(const IntSize& size)
{
if (!m_page || !usesContainerSize())
return;
LocalFrame* frame = m_page->mainFrame();
SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
if (!rootElement)
return;
RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
if (!renderer)
return;
FrameView* view = frameView();
view->resize(this->containerSize());
renderer->setContainerSize(size);
}
|
CWE-399
| 185,523 | 6,367 |
182241956130076800076466439157759499891
| null | null | null |
Chrome
|
59296d9276ffcc8bced092828210748d2ed19ab0
| 1 |
int32_t PepperFlashRendererHost::OnNavigate(
ppapi::host::HostMessageContext* host_context,
const ppapi::URLRequestInfoData& data,
const std::string& target,
bool from_user_action) {
content::PepperPluginInstance* plugin_instance =
host_->GetPluginInstance(pp_instance());
if (!plugin_instance)
return PP_ERROR_FAILED;
ppapi::proxy::HostDispatcher* host_dispatcher =
ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
host_dispatcher->set_allow_plugin_reentrancy();
base::WeakPtr<PepperFlashRendererHost> weak_ptr = weak_factory_.GetWeakPtr();
navigate_replies_.push_back(host_context->MakeReplyMessageContext());
plugin_instance->Navigate(data, target.c_str(), from_user_action);
if (weak_ptr.get()) {
SendReply(navigate_replies_.back(), IPC::Message());
navigate_replies_.pop_back();
}
return PP_OK_COMPLETIONPENDING;
}
|
CWE-399
| 185,526 | 6,370 |
228119142004611406326579459958987993918
| null | null | null |
Chrome
|
201d2ae4d50a755f3b4ba799c00590cfa2fe3b93
| 1 |
bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
content::SetContentClient(&content_client_);
content::RegisterMediaUrlInterceptor(new AwMediaUrlInterceptor());
BrowserViewRenderer::CalculateTileMemoryPolicy();
ui::GestureConfiguration::GetInstance()
->set_fling_touchscreen_tap_suppression_enabled(false);
base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
cl->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
cl->AppendSwitch(switches::kDisableOverscrollEdgeEffect);
cl->AppendSwitch(switches::kDisablePullToRefreshEffect);
cl->AppendSwitch(switches::kDisableSharedWorkers);
cl->AppendSwitch(switches::kDisableFileSystem);
cl->AppendSwitch(switches::kDisableNotifications);
cl->AppendSwitch(switches::kDisableWebRtcHWDecoding);
cl->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
cl->AppendSwitch(switches::kEnableThreadedTextureMailboxes);
cl->AppendSwitch(switches::kDisableScreenOrientationLock);
cl->AppendSwitch(switches::kDisableSpeechAPI);
cl->AppendSwitch(switches::kDisablePermissionsAPI);
cl->AppendSwitch(switches::kEnableAggressiveDOMStorageFlushing);
cl->AppendSwitch(switches::kDisablePresentationAPI);
if (cl->GetSwitchValueASCII(switches::kProcessType).empty()) {
#ifdef __LP64__
const char kNativesFileName[] = "assets/natives_blob_64.bin";
const char kSnapshotFileName[] = "assets/snapshot_blob_64.bin";
#else
const char kNativesFileName[] = "assets/natives_blob_32.bin";
const char kSnapshotFileName[] = "assets/snapshot_blob_32.bin";
#endif // __LP64__
CHECK(base::android::RegisterApkAssetWithGlobalDescriptors(
kV8NativesDataDescriptor, kNativesFileName));
CHECK(base::android::RegisterApkAssetWithGlobalDescriptors(
kV8SnapshotDataDescriptor, kSnapshotFileName));
}
if (cl->HasSwitch(switches::kWebViewSanboxedRenderer)) {
cl->AppendSwitch(switches::kInProcessGPU);
cl->AppendSwitchASCII(switches::kRendererProcessLimit, "1");
}
return false;
}
| 185,527 | 6,371 |
224669053130562284545869428768833465943
| null | null | null |
|
Chrome
|
c21d7ac13d69cbadbbb5b2dc147be1933d52147a
| 1 |
void ScreenPositionController::ConvertHostPointToRelativeToRootWindow(
aura::Window* root_window,
const aura::Window::Windows& root_windows,
gfx::Point* point,
aura::Window** target_root) {
DCHECK(!root_window->parent());
gfx::Point point_in_root(*point);
root_window->GetHost()->ConvertPointFromHost(&point_in_root);
*target_root = root_window;
*point = point_in_root;
#if defined(USE_X11) || defined(USE_OZONE)
if (!root_window->GetHost()->GetBounds().Contains(*point)) {
gfx::Point location_in_native(point_in_root);
root_window->GetHost()->ConvertPointToNativeScreen(&location_in_native);
for (size_t i = 0; i < root_windows.size(); ++i) {
aura::WindowTreeHost* host = root_windows[i]->GetHost();
const gfx::Rect native_bounds = host->GetBounds();
if (native_bounds.Contains(location_in_native)) {
*target_root = root_windows[i];
*point = location_in_native;
host->ConvertPointFromNativeScreen(point);
break;
}
}
}
#else
NOTIMPLEMENTED();
#endif
}
|
CWE-399
| 185,528 | 6,372 |
30125943252732387360073159409178562934
| null | null | null |
Chrome
|
e3de7fc7dbb642ed034afa1c1fed70a748a60f35
| 1 |
bool OverscrollControllerAndroid::Animate(base::TimeTicks current_time,
cc::Layer* parent_layer) {
DCHECK(parent_layer);
if (!enabled_)
return false;
return glow_effect_->Animate(current_time, parent_layer);
}
| 185,529 | 6,373 |
26404922818420300503524029498262772298
| null | null | null |
|
Chrome
|
8876cdc1294b2a10be1724a04f864c542e2d9b6f
| 1 |
void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement)
{
ASSERT(resultElement);
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return;
ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(targetElement));
ASSERT(percentage >= 0 && percentage <= 1);
ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGNames::animateTransformTag));
ASSERT(m_animatedPropertyType != AnimatedUnknown);
ASSERT(m_animator);
ASSERT(m_animator->type() == m_animatedPropertyType);
ASSERT(m_fromType);
ASSERT(m_fromType->type() == m_animatedPropertyType);
ASSERT(m_toType);
SVGAnimateElement* resultAnimationElement = toSVGAnimateElement(resultElement);
ASSERT(resultAnimationElement->m_animatedType);
ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyType);
if (hasTagName(SVGNames::setTag))
percentage = 1;
if (calcMode() == CalcModeDiscrete)
percentage = percentage < 0.5 ? 0 : 1;
m_animator->setContextElement(targetElement);
if (!m_animatedProperties.isEmpty())
m_animator->animValWillChange(m_animatedProperties);
SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationElement->m_animatedType.get());
}
| 185,532 | 6,376 |
321941795448642562950904928188143756451
| null | null | null |
|
Chrome
|
fc343fd48badc0158dc2bb763e9a8b9342f3cb6f
| 1 |
void FormAssociatedElement::formRemovedFromTree(const Node* formRoot)
{
ASSERT(m_form);
if (toHTMLElement(this)->highestAncestor() != formRoot)
setForm(0);
}
|
CWE-287
| 185,548 | 6,391 |
85267172430327177621585376321498143341
| null | null | null |
Chrome
|
b770d85e37b2d0e248f04cf20606a2f3871ef039
| 1 |
void WebPageSerializerImpl::openTagToString(Element* element,
SerializeDomParam* param)
{
bool needSkip;
StringBuilder result;
result.append(preActionBeforeSerializeOpenTag(element, param, &needSkip));
if (needSkip)
return;
result.append('<');
result.append(element->nodeName().lower());
AttributeCollection attributes = element->attributes();
AttributeCollection::iterator end = attributes.end();
for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it) {
result.append(' ');
result.append(it->name().toString());
result.appendLiteral("=\"");
if (!it->value().isEmpty()) {
const String& attrValue = it->value();
const QualifiedName& attrName = it->name();
if (element->hasLegalLinkAttribute(attrName)) {
if (attrValue.startsWith("javascript:", TextCaseInsensitive)) {
result.append(attrValue);
} else {
WebLocalFrameImpl* subFrame = WebLocalFrameImpl::fromFrameOwnerElement(element);
String completeURL = subFrame ? subFrame->frame()->document()->url() :
param->document->completeURL(attrValue);
if (m_localLinks.contains(completeURL)) {
if (!param->directoryName.isEmpty()) {
result.appendLiteral("./");
result.append(param->directoryName);
result.append('/');
}
result.append(m_localLinks.get(completeURL));
} else {
result.append(completeURL);
}
}
} else {
if (param->isHTMLDocument)
result.append(m_htmlEntities.convertEntitiesInString(attrValue));
else
result.append(m_xmlEntities.convertEntitiesInString(attrValue));
}
}
result.append('\"');
}
String addedContents = postActionAfterSerializeOpenTag(element, param);
if (element->hasChildren() || param->haveAddedContentsBeforeEnd)
result.append('>');
result.append(addedContents);
saveHTMLContentToBuffer(result.toString(), param);
}
|
CWE-20
| 185,604 | 6,439 |
87504207161441819280496849721385874131
| null | null | null |
Chrome
|
4c8b008f055f79e622344627fed7f820375a4f01
| 1 |
void Document::detach(const AttachContext& context)
{
TRACE_EVENT0("blink", "Document::detach");
ASSERT(!m_frame || m_frame->tree().childCount() == 0);
if (!isActive())
return;
FrameNavigationDisabler navigationDisabler(*m_frame);
HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
ScriptForbiddenScope forbidScript;
view()->dispose();
m_markers->prepareForDestruction();
if (LocalDOMWindow* window = this->domWindow())
window->willDetachDocumentFromFrame();
m_lifecycle.advanceTo(DocumentLifecycle::Stopping);
if (page())
page()->documentDetached(this);
InspectorInstrumentation::documentDetached(this);
if (m_frame->loader().client()->sharedWorkerRepositoryClient())
m_frame->loader().client()->sharedWorkerRepositoryClient()->documentDetached(this);
stopActiveDOMObjects();
if (m_scriptedAnimationController)
m_scriptedAnimationController->clearDocumentPointer();
m_scriptedAnimationController.clear();
m_scriptedIdleTaskController.clear();
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
if (m_domWindow)
m_domWindow->clearEventQueue();
if (m_layoutView)
m_layoutView->setIsInWindow(false);
if (registrationContext())
registrationContext()->documentWasDetached();
m_hoverNode = nullptr;
m_activeHoverElement = nullptr;
m_autofocusElement = nullptr;
if (m_focusedElement.get()) {
RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement;
m_focusedElement = nullptr;
if (frameHost())
frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get(), nullptr);
}
if (this == &axObjectCacheOwner())
clearAXObjectCache();
m_layoutView = nullptr;
ContainerNode::detach(context);
if (this != &axObjectCacheOwner()) {
if (AXObjectCache* cache = existingAXObjectCache()) {
for (Node& node : NodeTraversal::descendantsOf(*this)) {
cache->remove(&node);
}
}
}
styleEngine().didDetach();
frameHost()->eventHandlerRegistry().documentDetached(*this);
m_frame->inputMethodController().documentDetached();
if (!loader())
m_fetcher->clearContext();
if (m_importsController)
HTMLImportsController::removeFrom(*this);
m_timers.setTimerTaskRunner(
Platform::current()->currentThread()->scheduler()->timerTaskRunner()->adoptClone());
m_frame = nullptr;
if (m_mediaQueryMatcher)
m_mediaQueryMatcher->documentDetached();
DocumentLifecycleNotifier::notifyDocumentWasDetached();
m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
DocumentLifecycleNotifier::notifyContextDestroyed();
ExecutionContext::notifyContextDestroyed();
}
|
CWE-264
| 185,623 | 6,457 |
326911140912325092865415155923419708792
| null | null | null |
Chrome
|
0b1b7baa4695c945a1b0bea1f0636f1219139e8e
| 1 |
void DownloadUIAdapterDelegate::OpenItem(const OfflineItem& item,
int64_t offline_id) {
JNIEnv* env = AttachCurrentThread();
Java_OfflinePageDownloadBridge_openItem(
env, ConvertUTF8ToJavaString(env, item.page_url.spec()), offline_id);
}
|
CWE-264
| 185,628 | 6,462 |
61398520627540260125291026883091114452
| null | null | null |
Chrome
|
4026d85fcded8c4ee5113cb1bd1a7e8149e03827
| 1 |
static void GetLoadTimes(const v8::FunctionCallbackInfo<v8::Value>& args) {
WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext();
if (frame) {
WebDataSource* data_source = frame->dataSource();
if (data_source) {
DocumentState* document_state =
DocumentState::FromDataSource(data_source);
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> load_times = v8::Object::New(isolate);
load_times->Set(
v8::String::NewFromUtf8(isolate, "requestTime"),
v8::Number::New(isolate,
document_state->request_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "startLoadTime"),
v8::Number::New(isolate,
document_state->start_load_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "commitLoadTime"),
v8::Number::New(isolate,
document_state->commit_load_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "finishDocumentLoadTime"),
v8::Number::New(
isolate,
document_state->finish_document_load_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "finishLoadTime"),
v8::Number::New(isolate,
document_state->finish_load_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "firstPaintTime"),
v8::Number::New(isolate,
document_state->first_paint_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "firstPaintAfterLoadTime"),
v8::Number::New(
isolate,
document_state->first_paint_after_load_time().ToDoubleT()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "navigationType"),
v8::String::NewFromUtf8(
isolate, GetNavigationType(data_source->navigationType())));
load_times->Set(
v8::String::NewFromUtf8(isolate, "wasFetchedViaSpdy"),
v8::Boolean::New(isolate, document_state->was_fetched_via_spdy()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "wasNpnNegotiated"),
v8::Boolean::New(isolate, document_state->was_npn_negotiated()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "npnNegotiatedProtocol"),
v8::String::NewFromUtf8(
isolate, document_state->npn_negotiated_protocol().c_str()));
load_times->Set(
v8::String::NewFromUtf8(isolate, "wasAlternateProtocolAvailable"),
v8::Boolean::New(
isolate, document_state->was_alternate_protocol_available()));
load_times->Set(v8::String::NewFromUtf8(isolate, "connectionInfo"),
v8::String::NewFromUtf8(
isolate,
net::HttpResponseInfo::ConnectionInfoToString(
document_state->connection_info()).c_str()));
args.GetReturnValue().Set(load_times);
return;
}
}
args.GetReturnValue().SetNull();
}
| 185,643 | 6,475 |
277132746564241219790497811422210993037
| null | null | null |
|
Chrome
|
eb4d5d9ab41449b79fcf6f84d8983be2b12bd490
| 1 |
void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInsertionNotificationTargets)
{
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
if (!inDocument() && !node.isContainerNode())
continue;
if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.insertedInto(this))
postInsertionNotificationTargets.append(&node);
for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot())
notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTargets);
}
}
| 185,649 | 6,481 |
255915234708298251610702104516816201628
| null | null | null |
|
Chrome
|
d9e316238aee59acf665d80b544cf4e1edfd3349
| 1 |
int FindStartOffsetOfFileInZipFile(const char* zip_file, const char* filename) {
FileDescriptor fd;
if (!fd.OpenReadOnly(zip_file)) {
LOG_ERRNO("%s: open failed trying to open zip file %s\n",
__FUNCTION__, zip_file);
return CRAZY_OFFSET_FAILED;
}
struct stat stat_buf;
if (stat(zip_file, &stat_buf) == -1) {
LOG_ERRNO("%s: stat failed trying to stat zip file %s\n",
__FUNCTION__, zip_file);
return CRAZY_OFFSET_FAILED;
}
if (stat_buf.st_size > kMaxZipFileLength) {
LOG("%s: The size %ld of %s is too large to map\n",
__FUNCTION__, stat_buf.st_size, zip_file);
return CRAZY_OFFSET_FAILED;
}
void* mem = fd.Map(NULL, stat_buf.st_size, PROT_READ, MAP_PRIVATE, 0);
if (mem == MAP_FAILED) {
LOG_ERRNO("%s: mmap failed trying to mmap zip file %s\n",
__FUNCTION__, zip_file);
return CRAZY_OFFSET_FAILED;
}
ScopedMMap scoped_mmap(mem, stat_buf.st_size);
uint8_t* mem_bytes = static_cast<uint8_t*>(mem);
int off;
for (off = stat_buf.st_size - sizeof(kEndOfCentralDirectoryMarker);
off >= 0; --off) {
if (ReadUInt32(mem_bytes, off) == kEndOfCentralDirectoryMarker) {
break;
}
}
if (off == -1) {
LOG("%s: Failed to find end of central directory in %s\n",
__FUNCTION__, zip_file);
return CRAZY_OFFSET_FAILED;
}
uint32_t length_of_central_dir = ReadUInt32(
mem_bytes, off + kOffsetOfCentralDirLengthInEndOfCentralDirectory);
uint32_t start_of_central_dir = ReadUInt32(
mem_bytes, off + kOffsetOfStartOfCentralDirInEndOfCentralDirectory);
if (start_of_central_dir > off) {
LOG("%s: Found out of range offset %u for start of directory in %s\n",
__FUNCTION__, start_of_central_dir, zip_file);
return CRAZY_OFFSET_FAILED;
}
uint32_t end_of_central_dir = start_of_central_dir + length_of_central_dir;
if (end_of_central_dir > off) {
LOG("%s: Found out of range offset %u for end of directory in %s\n",
__FUNCTION__, end_of_central_dir, zip_file);
return CRAZY_OFFSET_FAILED;
}
uint32_t num_entries = ReadUInt16(
mem_bytes, off + kOffsetNumOfEntriesInEndOfCentralDirectory);
off = start_of_central_dir;
const int target_len = strlen(filename);
int n = 0;
for (; n < num_entries && off < end_of_central_dir; ++n) {
uint32_t marker = ReadUInt32(mem_bytes, off);
if (marker != kCentralDirHeaderMarker) {
LOG("%s: Failed to find central directory header marker in %s. "
"Found 0x%x but expected 0x%x\n", __FUNCTION__,
zip_file, marker, kCentralDirHeaderMarker);
return CRAZY_OFFSET_FAILED;
}
uint32_t file_name_length =
ReadUInt16(mem_bytes, off + kOffsetFilenameLengthInCentralDirectory);
uint32_t extra_field_length =
ReadUInt16(mem_bytes, off + kOffsetExtraFieldLengthInCentralDirectory);
uint32_t comment_field_length =
ReadUInt16(mem_bytes, off + kOffsetCommentLengthInCentralDirectory);
uint32_t header_length = kOffsetFilenameInCentralDirectory +
file_name_length + extra_field_length + comment_field_length;
uint32_t local_header_offset =
ReadUInt32(mem_bytes, off + kOffsetLocalHeaderOffsetInCentralDirectory);
uint8_t* filename_bytes =
mem_bytes + off + kOffsetFilenameInCentralDirectory;
if (file_name_length == target_len &&
memcmp(filename_bytes, filename, target_len) == 0) {
uint32_t marker = ReadUInt32(mem_bytes, local_header_offset);
if (marker != kLocalHeaderMarker) {
LOG("%s: Failed to find local file header marker in %s. "
"Found 0x%x but expected 0x%x\n", __FUNCTION__,
zip_file, marker, kLocalHeaderMarker);
return CRAZY_OFFSET_FAILED;
}
uint32_t compression_method =
ReadUInt16(
mem_bytes,
local_header_offset + kOffsetCompressionMethodInLocalHeader);
if (compression_method != kCompressionMethodStored) {
LOG("%s: %s is compressed within %s. "
"Found compression method %u but expected %u\n", __FUNCTION__,
filename, zip_file, compression_method, kCompressionMethodStored);
return CRAZY_OFFSET_FAILED;
}
uint32_t file_name_length =
ReadUInt16(
mem_bytes,
local_header_offset + kOffsetFilenameLengthInLocalHeader);
uint32_t extra_field_length =
ReadUInt16(
mem_bytes,
local_header_offset + kOffsetExtraFieldLengthInLocalHeader);
uint32_t header_length =
kOffsetFilenameInLocalHeader + file_name_length + extra_field_length;
return local_header_offset + header_length;
}
off += header_length;
}
if (n < num_entries) {
LOG("%s: Did not find all the expected entries in the central directory. "
"Found %d but expected %d\n", __FUNCTION__, n, num_entries);
}
if (off < end_of_central_dir) {
LOG("%s: There are %d extra bytes at the end of the central directory.\n",
__FUNCTION__, end_of_central_dir - off);
}
LOG("%s: Did not find %s in %s\n", __FUNCTION__, filename, zip_file);
return CRAZY_OFFSET_FAILED;
}
|
CWE-20
| 185,661 | 6,490 |
299890482944780715174523176757099473078
| null | null | null |
Chrome
|
5d0e9f824e05523e03dabc0e341b9f8f17a72bb0
| 1 |
bool CSPSourceList::matches(const KURL& url, ContentSecurityPolicy::RedirectStatus redirectStatus) const
{
if (m_allowStar)
return true;
KURL effectiveURL = m_policy->selfMatchesInnerURL() && SecurityOrigin::shouldUseInnerURL(url) ? SecurityOrigin::extractInnerURL(url) : url;
if (m_allowSelf && m_policy->urlMatchesSelf(effectiveURL))
return true;
for (size_t i = 0; i < m_list.size(); ++i) {
if (m_list[i].matches(effectiveURL, redirectStatus))
return true;
}
return false;
}
|
CWE-264
| 185,666 | 6,494 |
305681779156627635653657234398949354667
| null | null | null |
Chrome
|
c71a21e6dda9025c2bf823c5aab791c2ae8cdfc2
| 1 |
void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, Node& nextChild)
{
ASSERT(newChild);
ASSERT(nextChild.parentNode() == this);
ASSERT(!newChild->isDocumentFragment());
ASSERT(!isHTMLTemplateElement(this));
if (nextChild.previousSibling() == newChild || &nextChild == newChild) // nothing to do
return;
if (!checkParserAcceptChild(*newChild))
return;
RefPtrWillBeRawPtr<Node> protect(this);
while (RefPtrWillBeRawPtr<ContainerNode> parent = newChild->parentNode())
parent->parserRemoveChild(*newChild);
if (document() != newChild->document())
document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
{
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
treeScope().adoptIfNeeded(*newChild);
insertBeforeCommon(nextChild, *newChild);
newChild->updateAncestorConnectedSubframeCountForInsertion();
ChildListMutationScope(*this).childAdded(*newChild);
}
notifyNodeInserted(*newChild, ChildrenChangeSourceParser);
}
|
CWE-264
| 185,727 | 6,551 |
317084347252439648519934013274885137654
| null | null | null |
Chrome
|
f197c1c2b441da15274e2c17a928d7760b0bb260
| 1 |
void RenderViewTest::TearDown() {
base::RunLoop().RunUntilIdle();
ViewMsg_Close msg(view_->GetRoutingID());
static_cast<RenderViewImpl*>(view_)->OnMessageReceived(msg);
std::unique_ptr<blink::WebLeakDetector> leak_detector =
base::WrapUnique(blink::WebLeakDetector::Create(this));
leak_detector->PrepareForLeakDetection(view_->GetWebView()->MainFrame());
view_ = nullptr;
mock_process_.reset();
RenderThreadImpl::SetRendererBlinkPlatformImplForTesting(nullptr);
base::RunLoop().RunUntilIdle();
#if defined(OS_WIN)
ClearDWriteFontProxySenderForTesting();
#endif
#if defined(OS_MACOSX)
autorelease_pool_.reset();
#endif
leak_detector->CollectGarbageAndReport();
blink_platform_impl_.Shutdown();
platform_->PlatformUninitialize();
platform_.reset();
params_.reset();
command_line_.reset();
test_io_thread_.reset();
ipc_support_.reset();
}
| 185,739 | 6,563 |
9981115609144438894792818055874763318
| null | null | null |
|
Chrome
|
7ee897723127d0b8fecc5e67d45e20179c760e6e
| 1 |
ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigator, ExceptionState& exceptionState)
{
return NavigatorServiceWorker::from(navigator).serviceWorker(exceptionState);
}
|
CWE-264
| 185,740 | 6,564 |
109793506181312598859115178643790039479
| null | null | null |
Chrome
|
8fa5a358cb32085b51daf92df8fd4a79b3931f81
| 1 |
PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view,
scoped_ptr<Delegate> delegate)
: content::RenderViewObserver(render_view),
content::RenderViewObserverTracker<PrintWebViewHelper>(render_view),
reset_prep_frame_view_(false),
is_print_ready_metafile_sent_(false),
ignore_css_margins_(false),
is_scripted_printing_blocked_(false),
notify_browser_of_print_failure_(true),
print_for_preview_(false),
delegate_(delegate.Pass()),
print_node_in_progress_(false),
is_loading_(false),
is_scripted_preview_delayed_(false),
weak_ptr_factory_(this) {
if (!delegate_->IsPrintPreviewEnabled())
DisablePreview();
}
| 185,756 | 6,579 |
238300715503576856772676811739954152902
| null | null | null |
|
Chrome
|
1810bb5cec9026c64fc34fbbb8fafd01263241d2
| 1 |
void RenderThreadImpl::EnsureWebKitInitialized() {
if (webkit_platform_support_)
return;
webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl);
blink::initialize(webkit_platform_support_.get());
main_thread_compositor_task_runner_ =
make_scoped_refptr(new SchedulerProxyTaskRunner<
&blink::WebSchedulerProxy::postCompositorTask>());
v8::Isolate* isolate = blink::mainThreadIsolate();
isolate->SetCounterFunction(base::StatsTable::FindLocation);
isolate->SetCreateHistogramFunction(CreateHistogram);
isolate->SetAddHistogramSampleFunction(AddHistogramSample);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing);
if (enable) {
#if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance())
compositor_message_loop_proxy_ =
factory->GetCompositorMessageLoop();
#endif
if (!compositor_message_loop_proxy_.get()) {
compositor_thread_.reset(new base::Thread("Compositor"));
compositor_thread_->Start();
#if defined(OS_ANDROID)
compositor_thread_->SetPriority(base::kThreadPriority_Display);
#endif
compositor_message_loop_proxy_ =
compositor_thread_->message_loop_proxy();
compositor_message_loop_proxy_->PostTask(
FROM_HERE,
base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed),
false));
}
InputHandlerManagerClient* input_handler_manager_client = NULL;
#if defined(OS_ANDROID)
if (SynchronousCompositorFactory* factory =
SynchronousCompositorFactory::GetInstance()) {
input_handler_manager_client = factory->GetInputHandlerManagerClient();
}
#endif
if (!input_handler_manager_client) {
input_event_filter_ =
new InputEventFilter(this,
main_thread_compositor_task_runner_,
compositor_message_loop_proxy_);
AddFilter(input_event_filter_.get());
input_handler_manager_client = input_event_filter_.get();
}
input_handler_manager_.reset(
new InputHandlerManager(compositor_message_loop_proxy_,
input_handler_manager_client));
}
scoped_refptr<base::MessageLoopProxy> output_surface_loop;
if (enable)
output_surface_loop = compositor_message_loop_proxy_;
else
output_surface_loop = base::MessageLoopProxy::current();
compositor_output_surface_filter_ =
CompositorOutputSurface::CreateFilter(output_surface_loop.get());
AddFilter(compositor_output_surface_filter_.get());
RenderThreadImpl::RegisterSchemes();
EnableBlinkPlatformLogChannels(
command_line.GetSwitchValueASCII(switches::kBlinkPlatformLogChannels));
SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
if (!media::IsMediaLibraryInitialized()) {
WebRuntimeFeatures::enableWebAudio(false);
}
FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized());
devtools_agent_message_filter_ = new DevToolsAgentFilter();
AddFilter(devtools_agent_message_filter_.get());
if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden())
ScheduleIdleHandler(kLongIdleHandlerDelayMs);
cc_blink::SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction);
if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) &&
!is_impl_side_painting_enabled_)
SkGraphics::SetImageCacheByteLimit(0u);
SkGraphics::SetImageCacheSingleAllocationByteLimit(
kImageCacheSingleAllocationByteLimit);
if (command_line.HasSwitch(switches::kMemoryMetrics)) {
memory_observer_.reset(new MemoryObserver());
message_loop()->AddTaskObserver(memory_observer_.get());
}
}
| 185,764 | 6,586 |
270270925882228788322282577880326266629
| null | null | null |
|
Chrome
|
616568a633a3e2ae10537d14d3944d87ec382b8f
| 1 |
bool IsSiteMuted(const TabStripModel& tab_strip, const int index) {
content::WebContents* web_contents = tab_strip.GetWebContentsAt(index);
GURL url = web_contents->GetLastCommittedURL();
if (url.SchemeIs(content::kChromeUIScheme)) {
return web_contents->IsAudioMuted() &&
GetTabAudioMutedReason(web_contents) ==
TabMutedReason::CONTENT_SETTING_CHROME;
}
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
HostContentSettingsMap* settings =
HostContentSettingsMapFactory::GetForProfile(profile);
return settings->GetContentSetting(url, url, CONTENT_SETTINGS_TYPE_SOUND,
std::string()) == CONTENT_SETTING_BLOCK;
}
| 185,775 | 6,594 |
81731760281202610761563413828138177543
| null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.