instruction
stringclasses 1
value | input
stringlengths 64
129k
| output
int64 0
1
| __index_level_0__
int64 0
30k
|
|---|---|---|---|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: nfs4_file_get_access(struct nfs4_file *fp, u32 access)
{
lockdep_assert_held(&fp->fi_lock);
/* Does this access mode make sense? */
if (access & ~NFS4_SHARE_ACCESS_BOTH)
return nfserr_inval;
/* Does it conflict with a deny mode already set? */
if ((access & fp->fi_share_deny) != 0)
return nfserr_share_denied;
__nfs4_file_get_access(fp, access);
return nfs_ok;
}
Commit Message: Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields:
"Another RDMA update from Chuck Lever, and a bunch of miscellaneous
bugfixes"
* tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux: (26 commits)
nfsd: Fix up the "supattr_exclcreat" attributes
nfsd: encoders mustn't use unitialized values in error cases
nfsd: fix undefined behavior in nfsd4_layout_verify
lockd: fix lockd shutdown race
NFSv4: Fix callback server shutdown
SUNRPC: Refactor svc_set_num_threads()
NFSv4.x/callback: Create the callback service through svc_create_pooled
lockd: remove redundant check on block
svcrdma: Clean out old XDR encoders
svcrdma: Remove the req_map cache
svcrdma: Remove unused RDMA Write completion handler
svcrdma: Reduce size of sge array in struct svc_rdma_op_ctxt
svcrdma: Clean up RPC-over-RDMA backchannel reply processing
svcrdma: Report Write/Reply chunk overruns
svcrdma: Clean up RDMA_ERROR path
svcrdma: Use rdma_rw API in RPC reply path
svcrdma: Introduce local rdma_rw API helpers
svcrdma: Clean up svc_rdma_get_inv_rkey()
svcrdma: Add helper to save pages under I/O
svcrdma: Eliminate RPCRDMA_SQ_DEPTH_MULT
...
CWE ID: CWE-404
| 0
| 11,770
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: nautilus_file_operations_unmount_mount (GtkWindow *parent_window,
GMount *mount,
gboolean eject,
gboolean check_trash)
{
nautilus_file_operations_unmount_mount_full (parent_window, mount, NULL, eject,
check_trash, NULL, NULL);
}
Commit Message: mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991
CWE ID: CWE-20
| 0
| 23,687
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void AudioHandler::AddOutput(unsigned number_of_channels) {
DCHECK(IsMainThread());
outputs_.push_back(AudioNodeOutput::Create(this, number_of_channels));
GetNode()->DidAddOutput(NumberOfOutputs());
}
Commit Message: Revert "Keep AudioHandlers alive until they can be safely deleted."
This reverts commit 071df33edf2c8b4375fa432a83953359f93ea9e4.
Reason for revert:
This CL seems to cause an AudioNode leak on the Linux leak bot.
The log is:
https://ci.chromium.org/buildbot/chromium.webkit/WebKit%20Linux%20Trusty%20Leak/14252
* webaudio/AudioNode/audionode-connect-method-chaining.html
* webaudio/Panner/pannernode-basic.html
* webaudio/dom-exceptions.html
Original change's description:
> Keep AudioHandlers alive until they can be safely deleted.
>
> When an AudioNode is disposed, the handler is also disposed. But add
> the handler to the orphan list so that the handler stays alive until
> the context can safely delete it. If we don't do this, the handler
> may get deleted while the audio thread is processing the handler (due
> to, say, channel count changes and such).
>
> For an realtime context, always save the handler just in case the
> audio thread is running after the context is marked as closed (because
> the audio thread doesn't instantly stop when requested).
>
> For an offline context, only need to do this when the context is
> running because the context is guaranteed to be stopped if we're not
> in the running state. Hence, there's no possibility of deleting the
> handler while the graph is running.
>
> This is a revert of
> https://chromium-review.googlesource.com/c/chromium/src/+/860779, with
> a fix for the leak.
>
> Bug: 780919
> Change-Id: Ifb6b5fcf3fbc373f5779256688731245771da33c
> Reviewed-on: https://chromium-review.googlesource.com/862723
> Reviewed-by: Hongchan Choi <hongchan@chromium.org>
> Commit-Queue: Raymond Toy <rtoy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#528829}
TBR=rtoy@chromium.org,hongchan@chromium.org
Change-Id: Ibf406bf6ed34ea1f03e86a64a1e5ba6de0970c6f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 780919
Reviewed-on: https://chromium-review.googlesource.com/863402
Reviewed-by: Taiju Tsuiki <tzik@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528888}
CWE ID: CWE-416
| 0
| 11,139
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void TriggerShowLoginWizardFinish(
std::string switch_locale,
std::unique_ptr<ShowLoginWizardSwitchLanguageCallbackData> data) {
if (switch_locale.empty()) {
ShowLoginWizardFinish(data->first_screen, data->startup_manifest);
} else {
chromeos::locale_util::SwitchLanguageCallback callback(
base::Bind(&OnLanguageSwitchedCallback, base::Passed(std::move(data))));
chromeos::locale_util::SwitchLanguage(
switch_locale, true, true /* login_layouts_only */, callback,
ProfileManager::GetActiveUserProfile());
}
}
Commit Message: cros: Check initial auth type when showing views login.
Bug: 859611
Change-Id: I0298db9bbf4aed6bd40600aef2e1c5794e8cd058
Reviewed-on: https://chromium-review.googlesource.com/1123056
Reviewed-by: Xiaoyin Hu <xiaoyinh@chromium.org>
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572224}
CWE ID:
| 0
| 27,699
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RootWindow::SetGestureRecognizerForTesting(ui::GestureRecognizer* gr) {
gesture_recognizer_.reset(gr);
}
Commit Message: Introduce XGetImage() for GrabWindowSnapshot() in ChromeOS.
BUG=119492
TEST=manually done
Review URL: https://chromiumcodereview.appspot.com/10386124
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137556 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 13,152
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: AudioSystemImplTest()
: use_audio_thread_(GetParam()), audio_thread_("AudioSystemThread") {
if (use_audio_thread_) {
audio_thread_.StartAndWaitForTesting();
audio_manager_.reset(
new media::MockAudioManager(audio_thread_.task_runner()));
} else {
audio_manager_.reset(new media::MockAudioManager(
base::ThreadTaskRunnerHandle::Get().get()));
}
audio_manager_->SetInputStreamParameters(
media::AudioParameters::UnavailableDeviceParams());
audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
EXPECT_EQ(AudioSystem::Get(), audio_system_.get());
}
Commit Message: Switching AudioOutputAuthorizationHandler from using AudioManager interface to AudioSystem one.
BUG=672468
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Review-Url: https://codereview.chromium.org/2692203003
Cr-Commit-Position: refs/heads/master@{#450939}
CWE ID:
| 1
| 19,927
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, cond_update_fn_t update)
{
return -ENODEV;
}
Commit Message: Merge branch 'page-refs' (page ref overflow)
Merge page ref overflow branch.
Jann Horn reported that he can overflow the page ref count with
sufficient memory (and a filesystem that is intentionally extremely
slow).
Admittedly it's not exactly easy. To have more than four billion
references to a page requires a minimum of 32GB of kernel memory just
for the pointers to the pages, much less any metadata to keep track of
those pointers. Jann needed a total of 140GB of memory and a specially
crafted filesystem that leaves all reads pending (in order to not ever
free the page references and just keep adding more).
Still, we have a fairly straightforward way to limit the two obvious
user-controllable sources of page references: direct-IO like page
references gotten through get_user_pages(), and the splice pipe page
duplication. So let's just do that.
* branch page-refs:
fs: prevent page refcount overflow in pipe_buf_get
mm: prevent get_user_pages() from overflowing page refcount
mm: add 'try_get_page()' helper function
mm: make page ref count overflow check tighter and more explicit
CWE ID: CWE-416
| 0
| 10,272
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: explicit MockScriptLoader(Element* element) : ScriptLoader(element, false, false)
{
}
Commit Message: Add assertions that the empty Platform::cryptographicallyRandomValues() overrides are not being used.
These implementations are not safe and look scary if not accompanied by an assertion. Also one of the comments was incorrect.
BUG=552749
Review URL: https://codereview.chromium.org/1419293005
Cr-Commit-Position: refs/heads/master@{#359229}
CWE ID: CWE-310
| 0
| 7,996
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void MetricsLog::RecordCurrentSessionData(
DelegatingProvider* delegating_provider,
base::TimeDelta incremental_uptime,
base::TimeDelta uptime) {
DCHECK(!closed_);
DCHECK(has_environment_);
WriteRealtimeStabilityAttributes(incremental_uptime, uptime);
delegating_provider->ProvideCurrentSessionData(uma_proto());
}
Commit Message: Add CPU metrics provider and Add CPU/GPU provider for UKM.
Bug: 907674
Change-Id: I61b88aeac8d2a7ff81d812fa5a267f48203ec7e2
Reviewed-on: https://chromium-review.googlesource.com/c/1381376
Commit-Queue: Nik Bhagat <nikunjb@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618037}
CWE ID: CWE-79
| 0
| 14,364
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: OMX_ERRORTYPE omx_vdec::push_input_h264 (OMX_HANDLETYPE hComp)
{
OMX_U32 partial_frame = 1;
unsigned long address = 0, p2 = 0, id = 0;
OMX_BOOL isNewFrame = OMX_FALSE;
OMX_BOOL generate_ebd = OMX_TRUE;
if (h264_scratch.pBuffer == NULL) {
DEBUG_PRINT_ERROR("ERROR:H.264 Scratch Buffer not allocated");
return OMX_ErrorBadParameter;
}
DEBUG_PRINT_LOW("Pending h264_scratch.nFilledLen %u "
"look_ahead_nal %d", (unsigned int)h264_scratch.nFilledLen, look_ahead_nal);
DEBUG_PRINT_LOW("Pending pdest_frame->nFilledLen %u",(unsigned int)pdest_frame->nFilledLen);
if (h264_scratch.nFilledLen && look_ahead_nal) {
look_ahead_nal = false;
if ((pdest_frame->nAllocLen - pdest_frame->nFilledLen) >=
h264_scratch.nFilledLen) {
memcpy ((pdest_frame->pBuffer + pdest_frame->nFilledLen),
h264_scratch.pBuffer,h264_scratch.nFilledLen);
pdest_frame->nFilledLen += h264_scratch.nFilledLen;
DEBUG_PRINT_LOW("Copy the previous NAL (h264 scratch) into Dest frame");
h264_scratch.nFilledLen = 0;
} else {
DEBUG_PRINT_ERROR("Error:1: Destination buffer overflow for H264");
return OMX_ErrorBadParameter;
}
}
/* If an empty input is queued with EOS, do not coalesce with the destination-frame yet, as this may result
in EOS flag getting associated with the destination
*/
if (!psource_frame->nFilledLen && (psource_frame->nFlags & OMX_BUFFERFLAG_EOS) &&
pdest_frame->nFilledLen) {
DEBUG_PRINT_HIGH("delay ETB for 'empty buffer with EOS'");
generate_ebd = OMX_FALSE;
}
if (nal_length == 0) {
DEBUG_PRINT_LOW("Zero NAL, hence parse using start code");
if (m_frame_parser.parse_sc_frame(psource_frame,
&h264_scratch,&partial_frame) == -1) {
DEBUG_PRINT_ERROR("Error In Parsing Return Error");
return OMX_ErrorBadParameter;
}
} else {
DEBUG_PRINT_LOW("Non-zero NAL length clip, hence parse with NAL size %d ",nal_length);
if (m_frame_parser.parse_h264_nallength(psource_frame,
&h264_scratch,&partial_frame) == -1) {
DEBUG_PRINT_ERROR("Error In Parsing NAL size, Return Error");
return OMX_ErrorBadParameter;
}
}
if (partial_frame == 0) {
if (nal_count == 0 && h264_scratch.nFilledLen == 0) {
DEBUG_PRINT_LOW("First NAL with Zero Length, hence Skip");
nal_count++;
h264_scratch.nTimeStamp = psource_frame->nTimeStamp;
h264_scratch.nFlags = psource_frame->nFlags;
} else {
DEBUG_PRINT_LOW("Parsed New NAL Length = %u",(unsigned int)h264_scratch.nFilledLen);
if (h264_scratch.nFilledLen) {
h264_parser->parse_nal((OMX_U8*)h264_scratch.pBuffer, h264_scratch.nFilledLen,
NALU_TYPE_SPS);
#ifndef PROCESS_EXTRADATA_IN_OUTPUT_PORT
if (client_extradata & OMX_TIMEINFO_EXTRADATA)
h264_parser->parse_nal((OMX_U8*)h264_scratch.pBuffer,
h264_scratch.nFilledLen, NALU_TYPE_SEI);
else if (client_extradata & OMX_FRAMEINFO_EXTRADATA)
h264_parser->parse_nal((OMX_U8*)h264_scratch.pBuffer,
h264_scratch.nFilledLen, NALU_TYPE_SEI);
#endif
m_frame_parser.mutils->isNewFrame(&h264_scratch, 0, isNewFrame);
nal_count++;
if (VALID_TS(h264_last_au_ts) && !VALID_TS(pdest_frame->nTimeStamp)) {
pdest_frame->nTimeStamp = h264_last_au_ts;
pdest_frame->nFlags = h264_last_au_flags;
#ifdef PANSCAN_HDLR
if (client_extradata & OMX_FRAMEINFO_EXTRADATA)
h264_parser->update_panscan_data(h264_last_au_ts);
#endif
}
if (m_frame_parser.mutils->nalu_type == NALU_TYPE_NON_IDR ||
m_frame_parser.mutils->nalu_type == NALU_TYPE_IDR) {
h264_last_au_ts = h264_scratch.nTimeStamp;
h264_last_au_flags = h264_scratch.nFlags;
#ifndef PROCESS_EXTRADATA_IN_OUTPUT_PORT
if (client_extradata & OMX_TIMEINFO_EXTRADATA) {
OMX_S64 ts_in_sei = h264_parser->process_ts_with_sei_vui(h264_last_au_ts);
if (!VALID_TS(h264_last_au_ts))
h264_last_au_ts = ts_in_sei;
}
#endif
} else
h264_last_au_ts = LLONG_MAX;
}
if (!isNewFrame) {
if ( (pdest_frame->nAllocLen - pdest_frame->nFilledLen) >=
h264_scratch.nFilledLen) {
DEBUG_PRINT_LOW("Not a NewFrame Copy into Dest len %u",
(unsigned int)h264_scratch.nFilledLen);
memcpy ((pdest_frame->pBuffer + pdest_frame->nFilledLen),
h264_scratch.pBuffer,h264_scratch.nFilledLen);
pdest_frame->nFilledLen += h264_scratch.nFilledLen;
if (m_frame_parser.mutils->nalu_type == NALU_TYPE_EOSEQ)
pdest_frame->nFlags |= QOMX_VIDEO_BUFFERFLAG_EOSEQ;
h264_scratch.nFilledLen = 0;
} else {
DEBUG_PRINT_LOW("Error:2: Destination buffer overflow for H264");
return OMX_ErrorBadParameter;
}
} else if(h264_scratch.nFilledLen) {
look_ahead_nal = true;
DEBUG_PRINT_LOW("Frame Found start Decoding Size =%u TimeStamp = %llu",
(unsigned int)pdest_frame->nFilledLen,pdest_frame->nTimeStamp);
DEBUG_PRINT_LOW("Found a frame size = %u number = %d",
(unsigned int)pdest_frame->nFilledLen,frame_count++);
if (pdest_frame->nFilledLen == 0) {
DEBUG_PRINT_LOW("Copy the Current Frame since and push it");
look_ahead_nal = false;
if ( (pdest_frame->nAllocLen - pdest_frame->nFilledLen) >=
h264_scratch.nFilledLen) {
memcpy ((pdest_frame->pBuffer + pdest_frame->nFilledLen),
h264_scratch.pBuffer,h264_scratch.nFilledLen);
pdest_frame->nFilledLen += h264_scratch.nFilledLen;
h264_scratch.nFilledLen = 0;
} else {
DEBUG_PRINT_ERROR("Error:3: Destination buffer overflow for H264");
return OMX_ErrorBadParameter;
}
} else {
if (psource_frame->nFilledLen || h264_scratch.nFilledLen) {
DEBUG_PRINT_LOW("Reset the EOS Flag");
pdest_frame->nFlags &= ~OMX_BUFFERFLAG_EOS;
}
/*Push the frame to the Decoder*/
if (empty_this_buffer_proxy(hComp,pdest_frame) != OMX_ErrorNone) {
return OMX_ErrorBadParameter;
}
pdest_frame = NULL;
if (m_input_free_q.m_size) {
m_input_free_q.pop_entry(&address,&p2,&id);
pdest_frame = (OMX_BUFFERHEADERTYPE *) address;
DEBUG_PRINT_LOW("Pop the next pdest_buffer %p",pdest_frame);
pdest_frame->nFilledLen = 0;
pdest_frame->nFlags = 0;
pdest_frame->nTimeStamp = LLONG_MAX;
}
}
}
}
} else {
DEBUG_PRINT_LOW("Not a Complete Frame, pdest_frame->nFilledLen %u", (unsigned int)pdest_frame->nFilledLen);
/*Check if Destination Buffer is full*/
if (h264_scratch.nAllocLen ==
h264_scratch.nFilledLen + h264_scratch.nOffset) {
DEBUG_PRINT_ERROR("ERROR: Frame Not found though Destination Filled");
return OMX_ErrorStreamCorrupt;
}
}
if (!psource_frame->nFilledLen) {
DEBUG_PRINT_LOW("Buffer Consumed return source %p back to client",psource_frame);
if (psource_frame->nFlags & OMX_BUFFERFLAG_EOS) {
if (pdest_frame) {
DEBUG_PRINT_LOW("EOS Reached Pass Last Buffer");
if ( (pdest_frame->nAllocLen - pdest_frame->nFilledLen) >=
h264_scratch.nFilledLen) {
if(pdest_frame->nFilledLen == 0) {
/* No residual frame from before, send whatever
* we have left */
memcpy((pdest_frame->pBuffer + pdest_frame->nFilledLen),
h264_scratch.pBuffer, h264_scratch.nFilledLen);
pdest_frame->nFilledLen += h264_scratch.nFilledLen;
h264_scratch.nFilledLen = 0;
pdest_frame->nTimeStamp = h264_scratch.nTimeStamp;
} else {
m_frame_parser.mutils->isNewFrame(&h264_scratch, 0, isNewFrame);
if(!isNewFrame) {
/* Have a residual frame, but we know that the
* AU in this frame is belonging to whatever
* frame we had left over. So append it */
memcpy ((pdest_frame->pBuffer + pdest_frame->nFilledLen),
h264_scratch.pBuffer,h264_scratch.nFilledLen);
pdest_frame->nFilledLen += h264_scratch.nFilledLen;
h264_scratch.nFilledLen = 0;
if (h264_last_au_ts != LLONG_MAX)
pdest_frame->nTimeStamp = h264_last_au_ts;
} else {
/* Completely new frame, let's just push what
* we have now. The resulting EBD would trigger
* another push */
generate_ebd = OMX_FALSE;
pdest_frame->nTimeStamp = h264_last_au_ts;
h264_last_au_ts = h264_scratch.nTimeStamp;
}
}
} else {
DEBUG_PRINT_ERROR("ERROR:4: Destination buffer overflow for H264");
return OMX_ErrorBadParameter;
}
/* Iff we coalesced two buffers, inherit the flags of both bufs */
if(generate_ebd == OMX_TRUE) {
pdest_frame->nFlags = h264_scratch.nFlags | psource_frame->nFlags;
}
DEBUG_PRINT_LOW("pdest_frame->nFilledLen =%u TimeStamp = %llu",
(unsigned int)pdest_frame->nFilledLen,pdest_frame->nTimeStamp);
DEBUG_PRINT_LOW("Push AU frame number %d to driver", frame_count++);
#ifndef PROCESS_EXTRADATA_IN_OUTPUT_PORT
if (client_extradata & OMX_TIMEINFO_EXTRADATA) {
OMX_S64 ts_in_sei = h264_parser->process_ts_with_sei_vui(pdest_frame->nTimeStamp);
if (!VALID_TS(pdest_frame->nTimeStamp))
pdest_frame->nTimeStamp = ts_in_sei;
}
#endif
/*Push the frame to the Decoder*/
if (empty_this_buffer_proxy(hComp,pdest_frame) != OMX_ErrorNone) {
return OMX_ErrorBadParameter;
}
frame_count++;
pdest_frame = NULL;
} else {
DEBUG_PRINT_LOW("Last frame in else dest addr %p size %u",
pdest_frame, (unsigned int)h264_scratch.nFilledLen);
generate_ebd = OMX_FALSE;
}
}
}
if (generate_ebd && !psource_frame->nFilledLen) {
m_cb.EmptyBufferDone (hComp,m_app_data,psource_frame);
psource_frame = NULL;
if (m_input_pending_q.m_size) {
DEBUG_PRINT_LOW("Pull Next source Buffer %p",psource_frame);
m_input_pending_q.pop_entry(&address,&p2,&id);
psource_frame = (OMX_BUFFERHEADERTYPE *) address;
DEBUG_PRINT_LOW("Next source Buffer flag %u src length %u",
(unsigned int)psource_frame->nFlags, (unsigned int)psource_frame->nFilledLen);
}
}
return OMX_ErrorNone;
}
Commit Message: DO NOT MERGE mm-video-v4l2: vdec: Avoid processing ETBs/FTBs in invalid states
(per the spec) ETB/FTB should not be handled in states other than
Executing, Paused and Idle. This avoids accessing invalid buffers.
Also add a lock to protect the private-buffers from being deleted
while accessing from another thread.
Bug: 27890802
Security Vulnerability - Heap Use-After-Free and Possible LPE in
MediaServer (libOmxVdec problem #6)
CRs-Fixed: 1008882
Change-Id: Iaac2e383cd53cf9cf8042c9ed93ddc76dba3907e
CWE ID:
| 0
| 4,317
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) {
const int32 EGL_ALPHA_SIZE = 0x3021;
const int32 EGL_BLUE_SIZE = 0x3022;
const int32 EGL_GREEN_SIZE = 0x3023;
const int32 EGL_RED_SIZE = 0x3024;
const int32 EGL_DEPTH_SIZE = 0x3025;
const int32 EGL_STENCIL_SIZE = 0x3026;
const int32 EGL_SAMPLES = 0x3031;
const int32 EGL_SAMPLE_BUFFERS = 0x3032;
const int32 EGL_NONE = 0x3038;
for (size_t i = 0; i < attribs.size(); i += 2) {
const int32 attrib = attribs[i];
if (i + 1 >= attribs.size()) {
if (attrib == EGL_NONE)
return true;
DLOG(ERROR) << "Missing value after context creation attribute: "
<< attrib;
return false;
}
const int32 value = attribs[i+1];
switch (attrib) {
case EGL_ALPHA_SIZE:
alpha_size_ = value;
break;
case EGL_BLUE_SIZE:
blue_size_ = value;
break;
case EGL_GREEN_SIZE:
green_size_ = value;
break;
case EGL_RED_SIZE:
red_size_ = value;
break;
case EGL_DEPTH_SIZE:
depth_size_ = value;
break;
case EGL_STENCIL_SIZE:
stencil_size_ = value;
break;
case EGL_SAMPLES:
samples_ = value;
break;
case EGL_SAMPLE_BUFFERS:
sample_buffers_ = value;
break;
case EGL_NONE:
return true;
default:
DLOG(ERROR) << "Invalid context creation attribute: " << attrib;
return false;
}
}
return true;
}
Commit Message: Revert "Revert 100494 - Fix bug in SimulateAttrib0."""
TEST=none
BUG=95625
TBR=apatrick@chromium.org
Review URL: http://codereview.chromium.org/7796016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100507 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119
| 0
| 6,336
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool HTMLInputElement::IsValidValue(const String& value) const {
if (!input_type_->CanSetStringValue()) {
NOTREACHED();
return false;
}
return !input_type_->TypeMismatchFor(value) &&
!input_type_->StepMismatch(value) &&
!input_type_->RangeUnderflow(value) &&
!input_type_->RangeOverflow(value) &&
!TooLong(value, kIgnoreDirtyFlag) &&
!TooShort(value, kIgnoreDirtyFlag) &&
!input_type_->PatternMismatch(value) &&
!input_type_->ValueMissing(value);
}
Commit Message: MacViews: Enable secure text input for password Textfields.
In Cocoa the NSTextInputContext automatically enables secure text input
when activated and it's in the secure text entry mode.
RenderWidgetHostViewMac did the similar thing for ages following the
WebKit example.
views::Textfield needs to do the same thing in a fashion that's
sycnrhonized with RenderWidgetHostViewMac, otherwise the race conditions
are possible when the Textfield gets focus, activates the secure text
input mode and the RWHVM loses focus immediately afterwards and disables
the secure text input instead of leaving it in the enabled state.
BUG=818133,677220
Change-Id: I6db6c4b59e4a1a72cbb7f8c7056f71b04a3df08b
Reviewed-on: https://chromium-review.googlesource.com/943064
Commit-Queue: Michail Pishchagin <mblsha@yandex-team.ru>
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542517}
CWE ID:
| 0
| 28,292
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void sched_domains_numa_masks_clear(unsigned int cpu)
{
int i, j;
for (i = 0; i < sched_domains_numa_levels; i++) {
for (j = 0; j < nr_node_ids; j++)
cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]);
}
}
Commit Message: Merge branch 'stacking-fixes' (vfs stacking fixes from Jann)
Merge filesystem stacking fixes from Jann Horn.
* emailed patches from Jann Horn <jannh@google.com>:
sched: panic on corrupted stack end
ecryptfs: forbid opening files without mmap handler
proc: prevent stacking filesystems on top
CWE ID: CWE-119
| 0
| 18,171
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderThreadImpl::OnAssociatedInterfaceRequest(
const std::string& name,
mojo::ScopedInterfaceEndpointHandle handle) {
if (associated_interfaces_.CanBindRequest(name))
associated_interfaces_.BindRequest(name, std::move(handle));
else
ChildThreadImpl::OnAssociatedInterfaceRequest(name, std::move(handle));
}
Commit Message: Roll src/third_party/boringssl/src 664e99a64..696c13bd6
https://boringssl.googlesource.com/boringssl/+log/664e99a6486c293728097c661332f92bf2d847c6..696c13bd6ab78011adfe7b775519c8b7cc82b604
BUG=778101
Change-Id: I8dda4f3db952597148e3c7937319584698d00e1c
Reviewed-on: https://chromium-review.googlesource.com/747941
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: David Benjamin <davidben@chromium.org>
Commit-Queue: Steven Valdez <svaldez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513774}
CWE ID: CWE-310
| 0
| 1,028
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: size_t nw_buf_list_append(nw_buf_list *list, const void *data, size_t len)
{
if (list->limit && list->count >= list->limit)
return 0;
nw_buf *buf = nw_buf_alloc(list->pool);
if (buf == NULL)
return 0;
if (len > buf->size) {
nw_buf_free(list->pool, buf);
return 0;
}
nw_buf_write(buf, data, len);
if (list->head == NULL)
list->head = buf;
if (list->tail != NULL)
list->tail->next = buf;
list->tail = buf;
list->count++;
return len;
}
Commit Message: Merge pull request #131 from benjaminchodroff/master
fix memory corruption and other 32bit overflows
CWE ID: CWE-190
| 0
| 16,547
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: GF_Err stsz_dump(GF_Box *a, FILE * trace)
{
GF_SampleSizeBox *p;
u32 i;
p = (GF_SampleSizeBox *)a;
if (a->type == GF_ISOM_BOX_TYPE_STSZ) {
gf_isom_box_dump_start(a, "SampleSizeBox", trace);
}
else {
gf_isom_box_dump_start(a, "CompactSampleSizeBox", trace);
}
fprintf(trace, "SampleCount=\"%d\"", p->sampleCount);
if (a->type == GF_ISOM_BOX_TYPE_STSZ) {
if (p->sampleSize) {
fprintf(trace, " ConstantSampleSize=\"%d\"", p->sampleSize);
}
} else {
fprintf(trace, " SampleSizeBits=\"%d\"", p->sampleSize);
}
fprintf(trace, ">\n");
if ((a->type != GF_ISOM_BOX_TYPE_STSZ) || !p->sampleSize) {
if (!p->sizes && p->size) {
fprintf(trace, "<!--WARNING: No Sample Size indications-->\n");
} else {
for (i=0; i<p->sampleCount; i++) {
fprintf(trace, "<SampleSizeEntry Size=\"%d\"/>\n", p->sizes[i]);
}
}
}
if (!p->size) {
fprintf(trace, "<SampleSizeEntry Size=\"\"/>\n");
}
gf_isom_box_dump_done((a->type == GF_ISOM_BOX_TYPE_STSZ) ? "SampleSizeBox" : "CompactSampleSizeBox", a, trace);
return GF_OK;
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125
| 0
| 1,079
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: write_basic_field (DBusTypeWriter *writer,
int field,
int type,
const void *value)
{
DBusTypeWriter sub;
DBusTypeWriter variant;
int start;
int padding;
unsigned char field_byte;
DBusString contained_type;
char buf[2];
start = writer->value_pos;
padding = _dbus_string_get_length (writer->value_str) - start;
if (!_dbus_type_writer_recurse (writer, DBUS_TYPE_STRUCT,
NULL, 0, &sub))
goto append_failed;
field_byte = field;
if (!_dbus_type_writer_write_basic (&sub, DBUS_TYPE_BYTE,
&field_byte))
goto append_failed;
buf[0] = type;
buf[1] = '\0';
_dbus_string_init_const_len (&contained_type, buf, 1);
if (!_dbus_type_writer_recurse (&sub, DBUS_TYPE_VARIANT,
&contained_type, 0, &variant))
goto append_failed;
if (!_dbus_type_writer_write_basic (&variant, type, value))
goto append_failed;
if (!_dbus_type_writer_unrecurse (&sub, &variant))
goto append_failed;
if (!_dbus_type_writer_unrecurse (writer, &sub))
goto append_failed;
return TRUE;
append_failed:
_dbus_string_delete (writer->value_str,
start,
_dbus_string_get_length (writer->value_str) - start - padding);
return FALSE;
}
Commit Message:
CWE ID: CWE-20
| 0
| 21,550
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: __archive_write_nulls(struct archive_write *a, size_t length)
{
if (length == 0)
return (ARCHIVE_OK);
while (length > 0) {
size_t to_write = length < a->null_length ? length : a->null_length;
int r = __archive_write_output(a, a->nulls, to_write);
if (r < ARCHIVE_OK)
return (r);
length -= to_write;
}
return (ARCHIVE_OK);
}
Commit Message: Limit write requests to at most INT_MAX.
This prevents a certain common programming error (passing -1 to write)
from leading to other problems deeper in the library.
CWE ID: CWE-189
| 0
| 6,372
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8DebuggerScript>>& result)
{
v8::HandleScope scope(m_isolate);
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
DCHECK(!debuggerScript->IsUndefined());
v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts")));
v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) };
v8::Local<v8::Value> value;
if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, PROTOCOL_ARRAY_LENGTH(argv), argv).ToLocal(&value))
return;
DCHECK(value->IsArray());
v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value);
result.reserve(scriptsArray->Length());
for (unsigned i = 0; i < scriptsArray->Length(); ++i) {
v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(scriptsArray->Get(v8::Integer::New(m_isolate, i)));
result.push_back(wrapUnique(new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope)));
}
}
Commit Message: [DevTools] Copy objects from debugger context to inspected context properly.
BUG=637594
Review-Url: https://codereview.chromium.org/2253643002
Cr-Commit-Position: refs/heads/master@{#412436}
CWE ID: CWE-79
| 0
| 29,457
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void __exit hidp_cleanup_sockets(void)
{
bt_procfs_cleanup(&init_net, "hidp");
bt_sock_unregister(BTPROTO_HIDP);
proto_unregister(&hidp_proto);
}
Commit Message: Bluetooth: hidp: fix buffer overflow
Struct ca is copied from userspace. It is not checked whether the "name"
field is NULL terminated, which allows local users to obtain potentially
sensitive information from kernel stack memory, via a HIDPCONNADD command.
This vulnerability is similar to CVE-2011-1079.
Signed-off-by: Young Xiao <YangX92@hotmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
CWE ID: CWE-77
| 0
| 5,241
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void SiteInstanceImpl::SetSite(const GURL& url) {
TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite",
"site id", id_, "url", url.possibly_invalid_spec());
DCHECK(!has_site_);
has_site_ = true;
BrowserContext* browser_context = browsing_instance_->browser_context();
site_ = GetSiteForURL(browser_context, url);
original_url_ = url;
browsing_instance_->RegisterSiteInstance(this);
bool should_use_process_per_site =
RenderProcessHost::ShouldUseProcessPerSite(browser_context, site_);
if (should_use_process_per_site) {
process_reuse_policy_ = ProcessReusePolicy::PROCESS_PER_SITE;
}
if (process_) {
LockToOriginIfNeeded();
if (should_use_process_per_site) {
RenderProcessHostImpl::RegisterProcessHostForSite(
browser_context, process_, site_);
}
}
}
Commit Message: Use unique processes for data URLs on restore.
Data URLs are usually put into the process that created them, but this
info is not tracked after a tab restore. Ensure that they do not end up
in the parent frame's process (or each other's process), in case they
are malicious.
BUG=863069
Change-Id: Ib391f90c7bdf28a0a9c057c5cc7918c10aed968b
Reviewed-on: https://chromium-review.googlesource.com/1150767
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581023}
CWE ID: CWE-285
| 0
| 17,733
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderBox::updateFromStyle()
{
RenderBoxModelObject::updateFromStyle();
RenderStyle* styleToUse = style();
bool isRootObject = isDocumentElement();
bool isViewObject = isRenderView();
if (isRootObject || isViewObject)
setHasBoxDecorations(true);
setFloating(!isOutOfFlowPositioned() && styleToUse->isFloating());
bool boxHasOverflowClip = false;
if (!styleToUse->isOverflowVisible() && isRenderBlock() && !isViewObject) {
if (node() != document().viewportDefiningElement()) {
boxHasOverflowClip = true;
if (!hasOverflowClip()) {
if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
repaint();
}
}
}
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && (boxHasOverflowClip != hasOverflowClip())) {
for (RenderObject* child = firstChild(); child; child = child->nextSibling())
child->setShouldDoFullRepaintIfSelfPaintingLayer(true);
}
setHasOverflowClip(boxHasOverflowClip);
setHasTransform(styleToUse->hasTransformRelatedProperty());
setHasReflection(styleToUse->boxReflect());
}
Commit Message: Separate repaint and layout requirements of StyleDifference (Step 1)
Previously StyleDifference was an enum that proximately bigger values
imply smaller values (e.g. StyleDifferenceLayout implies
StyleDifferenceRepaint). This causes unnecessary repaints in some cases
on layout change.
Convert StyleDifference to a structure containing relatively independent
flags.
This change doesn't directly improve the result, but can make further
repaint optimizations possible.
Step 1 doesn't change any functionality. RenderStyle still generate the
legacy StyleDifference enum when comparing styles and convert the result
to the new StyleDifference. Implicit requirements are not handled during
the conversion.
Converted call sites to use the new StyleDifference according to the
following conversion rules:
- diff == StyleDifferenceEqual (&& !context) => diff.hasNoChange()
- diff == StyleDifferenceRepaint => diff.needsRepaintObjectOnly()
- diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff >= StyleDifferenceRepaint => diff.needsRepaint() || diff.needsLayout()
- diff >= StyleDifferenceRepaintLayer => diff.needsRepaintLayer() || diff.needsLayout()
- diff > StyleDifferenceRepaintLayer => diff.needsLayout()
- diff == StyleDifferencePositionedMovementLayoutOnly => diff.needsPositionedMovementLayoutOnly()
- diff == StyleDifferenceLayout => diff.needsFullLayout()
BUG=358460
TEST=All existing layout tests.
R=eseidel@chromium.org, esprehn@chromium.org, jchaffraix@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=171983
Review URL: https://codereview.chromium.org/236203020
git-svn-id: svn://svn.chromium.org/blink/trunk@172331 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119
| 0
| 13,067
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void open_logs(void)
{
int access_log;
/* if error_log_name is set, dup2 stderr to it */
/* otherwise, leave stderr alone */
/* we don't want to tie stderr to /dev/null */
if (error_log_name) {
int error_log;
/* open the log file */
error_log = open_gen_fd(error_log_name);
if (error_log < 0) {
DIE("unable to open error log");
}
/* redirect stderr to error_log */
if (dup2(error_log, STDERR_FILENO) == -1) {
DIE("unable to dup2 the error log");
}
close(error_log);
}
if (access_log_name) {
access_log = open_gen_fd(access_log_name);
} else {
access_log = open("/dev/null", 0);
}
if (access_log < 0) {
DIE("unable to open access log");
}
if (dup2(access_log, STDOUT_FILENO) == -1) {
DIE("can't dup2 /dev/null to STDOUT_FILENO");
}
if (fcntl(access_log, F_SETFD, 1) == -1) {
DIE("unable to set close-on-exec flag for access_log");
}
close(access_log);
if (cgi_log_name) {
cgi_log_fd = open_gen_fd(cgi_log_name);
if (cgi_log_fd == -1) {
WARN("open cgi_log");
free(cgi_log_name);
cgi_log_name = NULL;
cgi_log_fd = 0;
} else {
if (fcntl(cgi_log_fd, F_SETFD, 1) == -1) {
WARN("unable to set close-on-exec flag for cgi_log");
free(cgi_log_name);
cgi_log_name = NULL;
close(cgi_log_fd);
cgi_log_fd = 0;
}
}
}
#ifdef SETVBUF_REVERSED
setvbuf(stderr, _IONBF, (char *) NULL, 0);
setvbuf(stdout, _IOLBF, (char *) NULL, 0);
#else
setvbuf(stderr, (char *) NULL, _IONBF, 0);
setvbuf(stdout, (char *) NULL, _IOLBF, 0);
#endif
}
Commit Message: misc oom and possible memory leak fix
CWE ID:
| 0
| 2,085
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void CL_CDDialog( void ) {
cls.cddialog = qtrue; // start it next frame
}
Commit Message: All: Don't load .pk3s as .dlls, and don't load user config files from .pk3s
CWE ID: CWE-269
| 0
| 20,399
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: GetClientToServerResponseErrorType(
browser_sync::SyncProtocolErrorType error) {
switch (error) {
case browser_sync::SYNC_SUCCESS:
return sync_pb::SyncEnums::SUCCESS;
case browser_sync::NOT_MY_BIRTHDAY:
return sync_pb::SyncEnums::NOT_MY_BIRTHDAY;
case browser_sync::THROTTLED:
return sync_pb::SyncEnums::THROTTLED;
case browser_sync::CLEAR_PENDING:
return sync_pb::SyncEnums::CLEAR_PENDING;
case browser_sync::TRANSIENT_ERROR:
return sync_pb::SyncEnums::TRANSIENT_ERROR;
case browser_sync::MIGRATION_DONE:
return sync_pb::SyncEnums::MIGRATION_DONE;
case browser_sync::UNKNOWN_ERROR:
return sync_pb::SyncEnums::UNKNOWN;
default:
NOTREACHED();
return sync_pb::SyncEnums::UNKNOWN;
}
}
Commit Message: [Sync] Cleanup all tab sync enabling logic now that its on by default.
BUG=none
TEST=
Review URL: https://chromiumcodereview.appspot.com/10443046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139462 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-362
| 0
| 21,822
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: RGB_to_HWB (RGBType RGB, HWBType * HWB)
{
/*
* RGB are each on [0, 1]. W and B are returned on [0, 1] and H is
* returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B.
*/
float R = RGB.R, G = RGB.G, B = RGB.B, w, v, b, f;
int i;
w = MIN3 (R, G, B);
v = MAX3 (R, G, B);
b = 1 - v;
if (v == w)
RETURN_HWB (HWB_UNDEFINED, w, b);
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
i = (R == w) ? 3 : ((G == w) ? 5 : 1);
RETURN_HWB (i - f / (v - w), w, b);
}
Commit Message: Fix #340: System frozen
gdImageCreate() doesn't check for oversized images and as such is prone
to DoS vulnerabilities. We fix that by applying the same overflow check
that is already in place for gdImageCreateTrueColor().
CVE-2016-9317
CWE ID: CWE-20
| 0
| 505
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: gettime1900d(void)
{
struct timeval tv;
gettimeofday(&tv, NULL); /* never fails */
G.cur_time = tv.tv_sec + (1.0e-6 * tv.tv_usec) + OFFSET_1900_1970;
return G.cur_time;
}
Commit Message:
CWE ID: CWE-399
| 0
| 11,807
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int WriteWave64Header (FILE *outfile, WavpackContext *wpc, int64_t total_samples, int qmode)
{
Wave64ChunkHeader datahdr, fmthdr;
Wave64FileHeader filehdr;
WaveHeader wavhdr;
uint32_t bcount;
int64_t total_data_bytes, total_file_bytes;
int num_channels = WavpackGetNumChannels (wpc);
int32_t channel_mask = WavpackGetChannelMask (wpc);
int32_t sample_rate = WavpackGetSampleRate (wpc);
int bytes_per_sample = WavpackGetBytesPerSample (wpc);
int bits_per_sample = WavpackGetBitsPerSample (wpc);
int format = WavpackGetFloatNormExp (wpc) ? 3 : 1;
int wavhdrsize = 16;
if (format == 3 && WavpackGetFloatNormExp (wpc) != 127) {
error_line ("can't create valid Wave64 header for non-normalized floating data!");
return FALSE;
}
if (total_samples == -1)
total_samples = 0x7ffff000 / (bytes_per_sample * num_channels);
total_data_bytes = total_samples * bytes_per_sample * num_channels;
CLEAR (wavhdr);
wavhdr.FormatTag = format;
wavhdr.NumChannels = num_channels;
wavhdr.SampleRate = sample_rate;
wavhdr.BytesPerSecond = sample_rate * num_channels * bytes_per_sample;
wavhdr.BlockAlign = bytes_per_sample * num_channels;
wavhdr.BitsPerSample = bits_per_sample;
if (num_channels > 2 || channel_mask != 0x5 - num_channels) {
wavhdrsize = sizeof (wavhdr);
wavhdr.cbSize = 22;
wavhdr.ValidBitsPerSample = bits_per_sample;
wavhdr.SubFormat = format;
wavhdr.ChannelMask = channel_mask;
wavhdr.FormatTag = 0xfffe;
wavhdr.BitsPerSample = bytes_per_sample * 8;
wavhdr.GUID [4] = 0x10;
wavhdr.GUID [6] = 0x80;
wavhdr.GUID [9] = 0xaa;
wavhdr.GUID [11] = 0x38;
wavhdr.GUID [12] = 0x9b;
wavhdr.GUID [13] = 0x71;
}
total_file_bytes = sizeof (filehdr) + sizeof (fmthdr) + wavhdrsize + sizeof (datahdr) + ((total_data_bytes + 7) & ~(int64_t)7);
memcpy (filehdr.ckID, riff_guid, sizeof (riff_guid));
memcpy (filehdr.formType, wave_guid, sizeof (wave_guid));
filehdr.ckSize = total_file_bytes;
memcpy (fmthdr.ckID, fmt_guid, sizeof (fmt_guid));
fmthdr.ckSize = sizeof (fmthdr) + wavhdrsize;
memcpy (datahdr.ckID, data_guid, sizeof (data_guid));
datahdr.ckSize = total_data_bytes + sizeof (datahdr);
WavpackNativeToLittleEndian (&filehdr, Wave64ChunkHeaderFormat);
WavpackNativeToLittleEndian (&fmthdr, Wave64ChunkHeaderFormat);
WavpackNativeToLittleEndian (&wavhdr, WaveHeaderFormat);
WavpackNativeToLittleEndian (&datahdr, Wave64ChunkHeaderFormat);
if (!DoWriteFile (outfile, &filehdr, sizeof (filehdr), &bcount) || bcount != sizeof (filehdr) ||
!DoWriteFile (outfile, &fmthdr, sizeof (fmthdr), &bcount) || bcount != sizeof (fmthdr) ||
!DoWriteFile (outfile, &wavhdr, wavhdrsize, &bcount) || bcount != wavhdrsize ||
!DoWriteFile (outfile, &datahdr, sizeof (datahdr), &bcount) || bcount != sizeof (datahdr)) {
error_line ("can't write .W64 data, disk probably full!");
return FALSE;
}
return TRUE;
}
Commit Message: issue #33, sanitize size of unknown chunks before malloc()
CWE ID: CWE-787
| 0
| 14,818
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int f_midi_in_open(struct snd_rawmidi_substream *substream)
{
struct f_midi *midi = substream->rmidi->private_data;
struct gmidi_in_port *port;
if (substream->number >= midi->in_ports)
return -EINVAL;
VDBG(midi, "%s()\n", __func__);
port = midi->in_ports_array + substream->number;
port->substream = substream;
port->state = STATE_INITIAL;
return 0;
}
Commit Message: USB: gadget: f_midi: fixing a possible double-free in f_midi
It looks like there is a possibility of a double-free vulnerability on an
error path of the f_midi_set_alt function in the f_midi driver. If the
path is feasible then free_ep_req gets called twice:
req->complete = f_midi_complete;
err = usb_ep_queue(midi->out_ep, req, GFP_ATOMIC);
=> ...
usb_gadget_giveback_request
=>
f_midi_complete (CALLBACK)
(inside f_midi_complete, for various cases of status)
free_ep_req(ep, req); // first kfree
if (err) {
ERROR(midi, "%s: couldn't enqueue request: %d\n",
midi->out_ep->name, err);
free_ep_req(midi->out_ep, req); // second kfree
return err;
}
The double-free possibility was introduced with commit ad0d1a058eac
("usb: gadget: f_midi: fix leak on failed to enqueue out requests").
Found by MOXCAFE tool.
Signed-off-by: Tuba Yavuz <tuba@ece.ufl.edu>
Fixes: ad0d1a058eac ("usb: gadget: f_midi: fix leak on failed to enqueue out requests")
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-415
| 0
| 16,861
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void __init check_numabalancing_enable(void)
{
bool numabalancing_default = false;
if (IS_ENABLED(CONFIG_NUMA_BALANCING_DEFAULT_ENABLED))
numabalancing_default = true;
/* Parsed by setup_numabalancing. override == 1 enables, -1 disables */
if (numabalancing_override)
set_numabalancing_state(numabalancing_override == 1);
if (num_online_nodes() > 1 && !numabalancing_override) {
pr_info("%s automatic NUMA balancing. Configure with numa_balancing= or the kernel.numa_balancing sysctl\n",
numabalancing_default ? "Enabling" : "Disabling");
set_numabalancing_state(numabalancing_default);
}
}
Commit Message: mm/mempolicy.c: fix error handling in set_mempolicy and mbind.
In the case that compat_get_bitmap fails we do not want to copy the
bitmap to the user as it will contain uninitialized stack data and leak
sensitive data.
Signed-off-by: Chris Salls <salls@cs.ucsb.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-388
| 0
| 27,914
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: inline size_t SearchBuffer::search(size_t& start)
{
if (!m_isBufferFull)
return 0;
if (!m_isCharacterStartBuffer[m_cursor])
return 0;
size_t tailSpace = m_target.length() - m_cursor;
if (memcmp(&m_buffer[m_cursor], m_target.characters(), tailSpace * sizeof(UChar)) != 0)
return 0;
if (memcmp(&m_buffer[0], m_target.characters() + tailSpace, m_cursor * sizeof(UChar)) != 0)
return 0;
start = length();
m_isCharacterStartBuffer[m_cursor] = false;
return start;
}
Commit Message: Upgrade a TextIterator ASSERT to a RELEASE_ASSERT as a defensive measure.
BUG=156930,177197
R=inferno@chromium.org
Review URL: https://codereview.chromium.org/15057010
git-svn-id: svn://svn.chromium.org/blink/trunk@150123 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119
| 0
| 25,292
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool SocketStream::Delegate::CanGetCookies(SocketStream* socket,
const GURL& url) {
return true;
}
Commit Message: Revert a workaround commit for a Use-After-Free crash.
Revert a workaround commit r20158 for a Use-After-Free issue (http://crbug.com/244746) because a cleaner CL r207218 is landed.
URLRequestContext does not inherit SupportsWeakPtr now.
R=mmenke
BUG=244746
Review URL: https://chromiumcodereview.appspot.com/16870008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207811 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399
| 0
| 10,344
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void show_objects_for_type(
struct bitmap *objects,
struct ewah_bitmap *type_filter,
enum object_type object_type,
show_reachable_fn show_reach)
{
size_t pos = 0, i = 0;
uint32_t offset;
struct ewah_iterator it;
eword_t filter;
if (bitmap_git.reuse_objects == bitmap_git.pack->num_objects)
return;
ewah_iterator_init(&it, type_filter);
while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) {
eword_t word = objects->words[i] & filter;
for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
const unsigned char *sha1;
struct revindex_entry *entry;
uint32_t hash = 0;
if ((word >> offset) == 0)
break;
offset += ewah_bit_ctz64(word >> offset);
if (pos + offset < bitmap_git.reuse_objects)
continue;
entry = &bitmap_git.pack->revindex[pos + offset];
sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);
if (bitmap_git.hashes)
hash = ntohl(bitmap_git.hashes[entry->nr]);
show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
}
pos += BITS_IN_EWORD;
i++;
}
}
Commit Message: list-objects: pass full pathname to callbacks
When we find a blob at "a/b/c", we currently pass this to
our show_object_fn callbacks as two components: "a/b/" and
"c". Callbacks which want the full value then call
path_name(), which concatenates the two. But this is an
inefficient interface; the path is a strbuf, and we could
simply append "c" to it temporarily, then roll back the
length, without creating a new copy.
So we could improve this by teaching the callsites of
path_name() this trick (and there are only 3). But we can
also notice that no callback actually cares about the
broken-down representation, and simply pass each callback
the full path "a/b/c" as a string. The callback code becomes
even simpler, then, as we do not have to worry about freeing
an allocated buffer, nor rolling back our modification to
the strbuf.
This is theoretically less efficient, as some callbacks
would not bother to format the final path component. But in
practice this is not measurable. Since we use the same
strbuf over and over, our work to grow it is amortized, and
we really only pay to memcpy a few bytes.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
CWE ID: CWE-119
| 0
| 12,939
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
unsigned pte_access, int write_fault, int *emulate,
int level, gfn_t gfn, pfn_t pfn, bool speculative,
bool host_writable)
{
int was_rmapped = 0;
int rmap_count;
pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__,
*sptep, write_fault, gfn);
if (is_rmap_spte(*sptep)) {
/*
* If we overwrite a PTE page pointer with a 2MB PMD, unlink
* the parent of the now unreachable PTE.
*/
if (level > PT_PAGE_TABLE_LEVEL &&
!is_large_pte(*sptep)) {
struct kvm_mmu_page *child;
u64 pte = *sptep;
child = page_header(pte & PT64_BASE_ADDR_MASK);
drop_parent_pte(child, sptep);
kvm_flush_remote_tlbs(vcpu->kvm);
} else if (pfn != spte_to_pfn(*sptep)) {
pgprintk("hfn old %llx new %llx\n",
spte_to_pfn(*sptep), pfn);
drop_spte(vcpu->kvm, sptep);
kvm_flush_remote_tlbs(vcpu->kvm);
} else
was_rmapped = 1;
}
if (set_spte(vcpu, sptep, pte_access, level, gfn, pfn, speculative,
true, host_writable)) {
if (write_fault)
*emulate = 1;
kvm_mmu_flush_tlb(vcpu);
}
if (unlikely(is_mmio_spte(*sptep) && emulate))
*emulate = 1;
pgprintk("%s: setting spte %llx\n", __func__, *sptep);
pgprintk("instantiating %s PTE (%s) at %llx (%llx) addr %p\n",
is_large_pte(*sptep)? "2MB" : "4kB",
*sptep & PT_PRESENT_MASK ?"RW":"R", gfn,
*sptep, sptep);
if (!was_rmapped && is_large_pte(*sptep))
++vcpu->kvm->stat.lpages;
if (is_shadow_present_pte(*sptep)) {
if (!was_rmapped) {
rmap_count = rmap_add(vcpu, sptep, gfn);
if (rmap_count > RMAP_RECYCLE_THRESHOLD)
rmap_recycle(vcpu, sptep, gfn);
}
}
kvm_release_pfn_clean(pfn);
}
Commit Message: nEPT: Nested INVEPT
If we let L1 use EPT, we should probably also support the INVEPT instruction.
In our current nested EPT implementation, when L1 changes its EPT table
for L2 (i.e., EPT12), L0 modifies the shadow EPT table (EPT02), and in
the course of this modification already calls INVEPT. But if last level
of shadow page is unsync not all L1's changes to EPT12 are intercepted,
which means roots need to be synced when L1 calls INVEPT. Global INVEPT
should not be different since roots are synced by kvm_mmu_load() each
time EPTP02 changes.
Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: Nadav Har'El <nyh@il.ibm.com>
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
Signed-off-by: Xinhao Xu <xinhao.xu@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-20
| 0
| 25,946
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void HostCache::Entry::CountHit(bool hit_is_stale) {
++total_hits_;
if (hit_is_stale)
++stale_hits_;
}
Commit Message: Add PersistenceDelegate to HostCache
PersistenceDelegate is a new interface for persisting the contents of
the HostCache. This commit includes the interface itself, the logic in
HostCache for interacting with it, and a mock implementation of the
interface for testing. It does not include support for immediate data
removal since that won't be needed for the currently planned use case.
BUG=605149
Review-Url: https://codereview.chromium.org/2943143002
Cr-Commit-Position: refs/heads/master@{#481015}
CWE ID:
| 0
| 18,825
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static req_table_t* req_headers_in(request_rec *r)
{
req_table_t* t = apr_palloc(r->pool, sizeof(req_table_t));
t->r = r;
t->t = r->headers_in;
t->n = "headers_in";
return t;
}
Commit Message: *) SECURITY: CVE-2015-0228 (cve.mitre.org)
mod_lua: A maliciously crafted websockets PING after a script
calls r:wsupgrade() can cause a child process crash.
[Edward Lu <Chaosed0 gmail.com>]
Discovered by Guido Vranken <guidovranken gmail.com>
Submitted by: Edward Lu
Committed by: covener
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1657261 13f79535-47bb-0310-9956-ffa450edef68
CWE ID: CWE-20
| 0
| 16,149
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: PanoramiXRenderSetPictureFilter (ClientPtr client)
{
REQUEST(xRenderSetPictureFilterReq);
int result = Success, j;
PanoramiXRes *pict;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq);
VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess);
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client);
if(result != Success) break;
}
return result;
}
Commit Message:
CWE ID: CWE-20
| 0
| 423
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
{
tmsize_t stride = PredictorState(tif)->stride;
unsigned char* cp = (unsigned char*) cp0;
assert((cc%stride)==0);
if (cc > stride) {
/*
* Pipeline the most common cases.
*/
if (stride == 3) {
unsigned int cr = cp[0];
unsigned int cg = cp[1];
unsigned int cb = cp[2];
cc -= 3;
cp += 3;
while (cc>0) {
cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
cc -= 3;
cp += 3;
}
} else if (stride == 4) {
unsigned int cr = cp[0];
unsigned int cg = cp[1];
unsigned int cb = cp[2];
unsigned int ca = cp[3];
cc -= 4;
cp += 4;
while (cc>0) {
cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
cp[3] = (unsigned char) ((ca += cp[3]) & 0xff);
cc -= 4;
cp += 4;
}
} else {
cc -= stride;
do {
REPEAT4(stride, cp[stride] =
(unsigned char) ((cp[stride] + *cp) & 0xff); cp++)
cc -= stride;
} while (cc>0);
}
}
}
Commit Message: * libtiff/tif_predict.h, libtiff/tif_predict.c:
Replace assertions by runtime checks to avoid assertions in debug mode,
or buffer overflows in release mode. Can happen when dealing with
unusual tile size like YCbCr with subsampling. Reported as MSVR 35105
by Axel Souchet & Vishal Chauhan from the MSRC Vulnerabilities & Mitigations
team.
CWE ID: CWE-119
| 1
| 29,150
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int UDPSocketWin::CreateSocket(int addr_family) {
addr_family_ = addr_family;
socket_ = CreatePlatformSocket(addr_family_, SOCK_DGRAM, IPPROTO_UDP);
if (socket_ == INVALID_SOCKET)
return MapSystemError(WSAGetLastError());
core_ = new Core(this);
return OK;
}
Commit Message: Map posix error codes in bind better, and fix one windows mapping.
r=wtc
BUG=330233
Review URL: https://codereview.chromium.org/101193008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242224 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-416
| 0
| 10,227
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void WebLocalFrameImpl::ReloadImage(const WebNode& web_node) {
const Node* node = web_node.ConstUnwrap<Node>();
if (auto* image_element = ToHTMLImageElementOrNull(*node))
image_element->ForceReload();
}
Commit Message: Do not forward resource timing to parent frame after back-forward navigation
LocalFrame has |should_send_resource_timing_info_to_parent_| flag not to
send timing info to parent except for the first navigation. This flag is
cleared when the first timing is sent to parent, however this does not happen
if iframe's first navigation was by back-forward navigation. For such
iframes, we shouldn't send timings to parent at all.
Bug: 876822
Change-Id: I128b51a82ef278c439548afc8283ae63abdef5c5
Reviewed-on: https://chromium-review.googlesource.com/1186215
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585736}
CWE ID: CWE-200
| 0
| 5,404
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static UINT GetWinCP ( XMP_Uns16 macLang )
{
UINT winCP = 0;
if ( macLang <= 94 ) winCP = kMacToWinCP_0_94[macLang];
if ( winCP == 0 ) {
XMP_Uns16 macScript = GetMacScript ( macLang );
if ( macScript != kNoMacScript ) winCP = kMacScriptToWinCP[macScript];
}
return winCP;
} // GetWinCP
Commit Message:
CWE ID: CWE-835
| 0
| 28,356
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void netif_nit_deliver(struct sk_buff *skb)
{
struct packet_type *ptype;
if (list_empty(&ptype_all))
return;
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
skb->mac_len = skb->network_header - skb->mac_header;
rcu_read_lock();
list_for_each_entry_rcu(ptype, &ptype_all, list) {
if (!ptype->dev || ptype->dev == skb->dev)
deliver_skb(skb, ptype, skb->dev);
}
rcu_read_unlock();
}
Commit Message: veth: Dont kfree_skb() after dev_forward_skb()
In case of congestion, netif_rx() frees the skb, so we must assume
dev_forward_skb() also consume skb.
Bug introduced by commit 445409602c092
(veth: move loopback logic to common location)
We must change dev_forward_skb() to always consume skb, and veth to not
double free it.
Bug report : http://marc.info/?l=linux-netdev&m=127310770900442&w=3
Reported-by: Martín Ferrari <martin.ferrari@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-399
| 0
| 10,893
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: midi_synth_load_patch(int dev, int format, const char __user *addr,
int offs, int count, int pmgr_flag)
{
int orig_dev = synth_devs[dev]->midi_dev;
struct sysex_info sysex;
int i;
unsigned long left, src_offs, eox_seen = 0;
int first_byte = 1;
int hdr_size = (unsigned long) &sysex.data[0] - (unsigned long) &sysex;
leave_sysex(dev);
if (!prefix_cmd(orig_dev, 0xf0))
return 0;
if (format != SYSEX_PATCH)
{
/* printk("MIDI Error: Invalid patch format (key) 0x%x\n", format);*/
return -EINVAL;
}
if (count < hdr_size)
{
/* printk("MIDI Error: Patch header too short\n");*/
return -EINVAL;
}
count -= hdr_size;
/*
* Copy the header from user space but ignore the first bytes which have
* been transferred already.
*/
if(copy_from_user(&((char *) &sysex)[offs], &(addr)[offs], hdr_size - offs))
return -EFAULT;
if (count < sysex.len)
{
/* printk(KERN_WARNING "MIDI Warning: Sysex record too short (%d<%d)\n", count, (int) sysex.len);*/
sysex.len = count;
}
left = sysex.len;
src_offs = 0;
for (i = 0; i < left && !signal_pending(current); i++)
{
unsigned char data;
if (get_user(data,
(unsigned char __user *)(addr + hdr_size + i)))
return -EFAULT;
eox_seen = (i > 0 && data & 0x80); /* End of sysex */
if (eox_seen && data != 0xf7)
data = 0xf7;
if (i == 0)
{
if (data != 0xf0)
{
printk(KERN_WARNING "midi_synth: Sysex start missing\n");
return -EINVAL;
}
}
while (!midi_devs[orig_dev]->outputc(orig_dev, (unsigned char) (data & 0xff)) &&
!signal_pending(current))
schedule();
if (!first_byte && data & 0x80)
return 0;
first_byte = 0;
}
if (!eox_seen)
midi_outc(orig_dev, 0xf7);
return 0;
}
Commit Message: sound/oss: remove offset from load_patch callbacks
Was: [PATCH] sound/oss/midi_synth: prevent underflow, use of
uninitialized value, and signedness issue
The offset passed to midi_synth_load_patch() can be essentially
arbitrary. If it's greater than the header length, this will result in
a copy_from_user(dst, src, negative_val). While this will just return
-EFAULT on x86, on other architectures this may cause memory corruption.
Additionally, the length field of the sysex_info structure may not be
initialized prior to its use. Finally, a signed comparison may result
in an unintentionally large loop.
On suggestion by Takashi Iwai, version two removes the offset argument
from the load_patch callbacks entirely, which also resolves similar
issues in opl3. Compile tested only.
v3 adjusts comments and hopefully gets copy offsets right.
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CWE ID: CWE-189
| 1
| 4,574
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void __ref free_initmem(void)
{
e820_reallocate_tables();
free_init_pages("unused kernel",
(unsigned long)(&__init_begin),
(unsigned long)(&__init_end));
}
Commit Message: mm: Tighten x86 /dev/mem with zeroing reads
Under CONFIG_STRICT_DEVMEM, reading System RAM through /dev/mem is
disallowed. However, on x86, the first 1MB was always allowed for BIOS
and similar things, regardless of it actually being System RAM. It was
possible for heap to end up getting allocated in low 1MB RAM, and then
read by things like x86info or dd, which would trip hardened usercopy:
usercopy: kernel memory exposure attempt detected from ffff880000090000 (dma-kmalloc-256) (4096 bytes)
This changes the x86 exception for the low 1MB by reading back zeros for
System RAM areas instead of blindly allowing them. More work is needed to
extend this to mmap, but currently mmap doesn't go through usercopy, so
hardened usercopy won't Oops the kernel.
Reported-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Tested-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
CWE ID: CWE-732
| 0
| 28,295
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: nautilus_mime_file_extracts (NautilusFile *file)
{
return get_activation_action (file) == ACTIVATION_ACTION_EXTRACT;
}
Commit Message: mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991
CWE ID: CWE-20
| 0
| 22,341
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: InfoBarService* infobar_service() {
return InfoBarService::FromWebContents(web_contents());
}
Commit Message: Fix UAF in Origin Info Bubble and permission settings UI.
In addition to fixing the UAF, will this also fix the problem of the bubble
showing over the previous tab (if the bubble is open when the tab it was opened
for closes).
BUG=490492
TBR=tedchoc
Review URL: https://codereview.chromium.org/1317443002
Cr-Commit-Position: refs/heads/master@{#346023}
CWE ID:
| 0
| 1,244
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def,
enum merge_mode merge)
{
LedNameInfo ledi;
xkb_atom_t name;
if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) {
info->errorCount++;
log_err(info->ctx,
"Illegal indicator index (%d) specified; must be between 1 .. %d; "
"Ignored\n", def->ndx, XKB_MAX_LEDS);
return false;
}
if (!ExprResolveString(info->ctx, def->name, &name)) {
char buf[20];
snprintf(buf, sizeof(buf), "%u", def->ndx);
info->errorCount++;
return ReportBadType(info->ctx, "indicator", "name", buf, "string");
}
ledi.merge = merge;
ledi.name = name;
return AddLedName(info, merge, true, &ledi, def->ndx - 1);
}
Commit Message: keycodes: don't try to copy zero key aliases
Move the aliases copy to within the (num_key_aliases > 0) block.
Passing info->aliases into this fuction with invalid aliases will
cause log messages but num_key_aliases stays on 0. The key_aliases array
is never allocated and remains NULL. We then loop through the aliases, causing
a null-pointer dereference.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
CWE ID: CWE-476
| 0
| 19,403
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: DevToolsWindow::FrontendWebContentsObserver::FrontendWebContentsObserver(
DevToolsWindow* devtools_window)
: WebContentsObserver(devtools_window->web_contents()),
devtools_window_(devtools_window) {
}
Commit Message: DevTools: handle devtools renderer unresponsiveness during beforeunload event interception
This patch fixes the crash which happenes under the following conditions:
1. DevTools window is in undocked state
2. DevTools renderer is unresponsive
3. User attempts to close inspected page
BUG=322380
Review URL: https://codereview.chromium.org/84883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237611 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-264
| 0
| 1,577
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void comps_objrtree_data_destroy(COMPS_ObjRTreeData * rtd) {
free(rtd->key);
comps_object_destroy(rtd->data);
comps_hslist_destroy(&rtd->subnodes);
free(rtd);
}
Commit Message: Fix UAF in comps_objmrtree_unite function
The added field is not used at all in many places and it is probably the
left-over of some copy-paste.
CWE ID: CWE-416
| 0
| 1,022
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void ExtensionGlobalError::BubbleViewAcceptButtonPressed() {
if (!accept_callback_.is_null()) {
accept_callback_.Run(*this, current_browser_);
}
}
Commit Message: [i18n-fixlet] Make strings branding specific in extension code.
IDS_EXTENSIONS_UNINSTALL
IDS_EXTENSIONS_INCOGNITO_WARNING
IDS_EXTENSION_INSTALLED_HEADING
IDS_EXTENSION_ALERT_ITEM_EXTERNAL And fix a $1 $1 bug.
IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/9107061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118018 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119
| 0
| 10,724
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
struct packet_sock *po = pkt_sk(sk);
int ret;
if (level != SOL_PACKET)
return -ENOPROTOOPT;
switch (optname) {
case PACKET_ADD_MEMBERSHIP:
case PACKET_DROP_MEMBERSHIP:
{
struct packet_mreq_max mreq;
int len = optlen;
memset(&mreq, 0, sizeof(mreq));
if (len < sizeof(struct packet_mreq))
return -EINVAL;
if (len > sizeof(mreq))
len = sizeof(mreq);
if (copy_from_user(&mreq, optval, len))
return -EFAULT;
if (len < (mreq.mr_alen + offsetof(struct packet_mreq, mr_address)))
return -EINVAL;
if (optname == PACKET_ADD_MEMBERSHIP)
ret = packet_mc_add(sk, &mreq);
else
ret = packet_mc_drop(sk, &mreq);
return ret;
}
case PACKET_RX_RING:
case PACKET_TX_RING:
{
struct tpacket_req req;
if (optlen < sizeof(req))
return -EINVAL;
if (pkt_sk(sk)->has_vnet_hdr)
return -EINVAL;
if (copy_from_user(&req, optval, sizeof(req)))
return -EFAULT;
return packet_set_ring(sk, &req, 0, optname == PACKET_TX_RING);
}
case PACKET_COPY_THRESH:
{
int val;
if (optlen != sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
pkt_sk(sk)->copy_thresh = val;
return 0;
}
case PACKET_VERSION:
{
int val;
if (optlen != sizeof(val))
return -EINVAL;
if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
return -EBUSY;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
switch (val) {
case TPACKET_V1:
case TPACKET_V2:
po->tp_version = val;
return 0;
default:
return -EINVAL;
}
}
case PACKET_RESERVE:
{
unsigned int val;
if (optlen != sizeof(val))
return -EINVAL;
if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
return -EBUSY;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->tp_reserve = val;
return 0;
}
case PACKET_LOSS:
{
unsigned int val;
if (optlen != sizeof(val))
return -EINVAL;
if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
return -EBUSY;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->tp_loss = !!val;
return 0;
}
case PACKET_AUXDATA:
{
int val;
if (optlen < sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->auxdata = !!val;
return 0;
}
case PACKET_ORIGDEV:
{
int val;
if (optlen < sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->origdev = !!val;
return 0;
}
case PACKET_VNET_HDR:
{
int val;
if (sock->type != SOCK_RAW)
return -EINVAL;
if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
return -EBUSY;
if (optlen < sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->has_vnet_hdr = !!val;
return 0;
}
case PACKET_TIMESTAMP:
{
int val;
if (optlen != sizeof(val))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
po->tp_tstamp = val;
return 0;
}
default:
return -ENOPROTOOPT;
}
}
Commit Message: af_packet: prevent information leak
In 2.6.27, commit 393e52e33c6c2 (packet: deliver VLAN TCI to userspace)
added a small information leak.
Add padding field and make sure its zeroed before copy to user.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-264
| 0
| 4,242
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: parsefattr(netdissect_options *ndo,
const uint32_t *dp, int verbose, int v3)
{
const struct nfs_fattr *fap;
fap = (const struct nfs_fattr *)dp;
ND_TCHECK(fap->fa_gid);
if (verbose) {
ND_PRINT((ndo, " %s %o ids %d/%d",
tok2str(type2str, "unk-ft %d ",
EXTRACT_32BITS(&fap->fa_type)),
EXTRACT_32BITS(&fap->fa_mode),
EXTRACT_32BITS(&fap->fa_uid),
EXTRACT_32BITS(&fap->fa_gid)));
if (v3) {
ND_TCHECK(fap->fa3_size);
ND_PRINT((ndo, " sz %" PRIu64,
EXTRACT_64BITS((const uint32_t *)&fap->fa3_size)));
} else {
ND_TCHECK(fap->fa2_size);
ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size)));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
ND_TCHECK(fap->fa3_ctime);
ND_PRINT((ndo, " nlink %d rdev %d/%d",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
EXTRACT_32BITS(&fap->fa3_rdev.specdata2)));
ND_PRINT((ndo, " fsid %" PRIx64,
EXTRACT_64BITS((const uint32_t *)&fap->fa3_fsid)));
ND_PRINT((ndo, " fileid %" PRIx64,
EXTRACT_64BITS((const uint32_t *)&fap->fa3_fileid)));
ND_PRINT((ndo, " a/m/ctime %u.%06u",
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec)));
ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec),
EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec)));
ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec),
EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec)));
} else {
ND_TCHECK(fap->fa2_ctime);
ND_PRINT((ndo, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa2_rdev),
EXTRACT_32BITS(&fap->fa2_fsid),
EXTRACT_32BITS(&fap->fa2_fileid)));
ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec),
EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec)));
ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec),
EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec)));
ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec),
EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)));
}
}
return ((const uint32_t *)((const unsigned char *)dp +
(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
trunc:
return (NULL);
}
Commit Message: CVE-2017-13005/NFS: Add two bounds checks before fetching data
This fixes a buffer over-read discovered by Kamil Frankowicz.
Add a test using the capture file supplied by the reporter(s).
CWE ID: CWE-125
| 0
| 23,321
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
{
#ifdef CONFIG_HIGHMEM
int i;
if (!(dev->features & NETIF_F_HIGHDMA)) {
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
if (PageHighMem(skb_frag_page(frag)))
return 1;
}
}
if (PCI_DMA_BUS_IS_PHYS) {
struct device *pdev = dev->dev.parent;
if (!pdev)
return 0;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
dma_addr_t addr = page_to_phys(skb_frag_page(frag));
if (!pdev->dma_mask || addr + PAGE_SIZE - 1 > *pdev->dma_mask)
return 1;
}
}
#endif
return 0;
}
Commit Message: tun: call dev_get_valid_name() before register_netdevice()
register_netdevice() could fail early when we have an invalid
dev name, in which case ->ndo_uninit() is not called. For tun
device, this is a problem because a timer etc. are already
initialized and it expects ->ndo_uninit() to clean them up.
We could move these initializations into a ->ndo_init() so
that register_netdevice() knows better, however this is still
complicated due to the logic in tun_detach().
Therefore, I choose to just call dev_get_valid_name() before
register_netdevice(), which is quicker and much easier to audit.
And for this specific case, it is already enough.
Fixes: 96442e42429e ("tuntap: choose the txq based on rxq")
Reported-by: Dmitry Alexeev <avekceeb@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-476
| 0
| 12,284
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: u32 ip_idents_reserve(u32 hash, int segs)
{
u32 *p_tstamp = ip_tstamps + hash % IP_IDENTS_SZ;
atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
u32 old = READ_ONCE(*p_tstamp);
u32 now = (u32)jiffies;
u32 new, delta = 0;
if (old != now && cmpxchg(p_tstamp, old, now) == old)
delta = prandom_u32_max(now - old);
/* Do not use atomic_add_return() as it makes UBSAN unhappy */
do {
old = (u32)atomic_read(p_id);
new = old + delta + segs;
} while (atomic_cmpxchg(p_id, old, new) != old);
return new - segs;
}
Commit Message: inet: switch IP ID generator to siphash
According to Amit Klein and Benny Pinkas, IP ID generation is too weak
and might be used by attackers.
Even with recent net_hash_mix() fix (netns: provide pure entropy for net_hash_mix())
having 64bit key and Jenkins hash is risky.
It is time to switch to siphash and its 128bit keys.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Amit Klein <aksecurity@gmail.com>
Reported-by: Benny Pinkas <benny@pinkas.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-200
| 0
| 12,547
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void metx_del(GF_Box *s)
{
GF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox*)s;
if (ptr == NULL) return;
gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s);
if (ptr->content_encoding) gf_free(ptr->content_encoding);
if (ptr->xml_namespace) gf_free(ptr->xml_namespace);
if (ptr->xml_schema_loc) gf_free(ptr->xml_schema_loc);
if (ptr->mime_type) gf_free(ptr->mime_type);
if (ptr->config) gf_isom_box_del((GF_Box *)ptr->config);
gf_free(ptr);
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125
| 0
| 14,491
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderFrameImpl::didFailLoad(blink::WebLocalFrame* frame,
const blink::WebURLError& error) {
DCHECK(!frame_ || frame_ == frame);
WebDataSource* ds = frame->dataSource();
DCHECK(ds);
FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
DidFailLoad(frame, error));
const WebURLRequest& failed_request = ds->request();
base::string16 error_description;
GetContentClient()->renderer()->GetNavigationErrorStrings(
render_view_.get(),
frame,
failed_request,
error,
NULL,
&error_description);
Send(new FrameHostMsg_DidFailLoadWithError(routing_id_,
failed_request.url(),
error.reason,
error_description));
}
Commit Message: Add logging to figure out which IPC we're failing to deserialize in RenderFrame.
BUG=369553
R=creis@chromium.org
Review URL: https://codereview.chromium.org/263833020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268565 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399
| 0
| 23,475
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: copy_attr (char const *src_path, char const *dst_path)
{
return 0;
}
Commit Message:
CWE ID: CWE-59
| 0
| 18,817
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void qeth_idx_read_cb(struct qeth_channel *channel,
struct qeth_cmd_buffer *iob)
{
struct qeth_card *card;
__u16 temp;
QETH_DBF_TEXT(SETUP , 2, "idxrdcb");
if (channel->state == CH_STATE_DOWN) {
channel->state = CH_STATE_ACTIVATING;
goto out;
}
card = CARD_FROM_CDEV(channel->ccwdev);
if (qeth_check_idx_response(card, iob->data))
goto out;
if (!(QETH_IS_IDX_ACT_POS_REPLY(iob->data))) {
switch (QETH_IDX_ACT_CAUSE_CODE(iob->data)) {
case QETH_IDX_ACT_ERR_EXCL:
dev_err(&card->write.ccwdev->dev,
"The adapter is used exclusively by another "
"host\n");
break;
case QETH_IDX_ACT_ERR_AUTH:
case QETH_IDX_ACT_ERR_AUTH_USER:
dev_err(&card->read.ccwdev->dev,
"Setting the device online failed because of "
"insufficient authorization\n");
break;
default:
QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on read channel:"
" negative reply\n",
dev_name(&card->read.ccwdev->dev));
}
QETH_CARD_TEXT_(card, 2, "idxread%c",
QETH_IDX_ACT_CAUSE_CODE(iob->data));
goto out;
}
/**
* * temporary fix for microcode bug
* * to revert it,replace OR by AND
* */
if ((!QETH_IDX_NO_PORTNAME_REQUIRED(iob->data)) ||
(card->info.type == QETH_CARD_TYPE_OSD))
card->info.portname_required = 1;
memcpy(&temp, QETH_IDX_ACT_FUNC_LEVEL(iob->data), 2);
if (temp != qeth_peer_func_level(card->info.func_level)) {
QETH_DBF_MESSAGE(2, "%s IDX_ACTIVATE on read channel: function "
"level mismatch (sent: 0x%x, received: 0x%x)\n",
dev_name(&card->read.ccwdev->dev),
card->info.func_level, temp);
goto out;
}
memcpy(&card->token.issuer_rm_r,
QETH_IDX_ACT_ISSUER_RM_TOKEN(iob->data),
QETH_MPC_TOKEN_LENGTH);
memcpy(&card->info.mcl_level[0],
QETH_IDX_REPLY_LEVEL(iob->data), QETH_MCL_LENGTH);
channel->state = CH_STATE_UP;
out:
qeth_release_buffer(channel, iob);
}
Commit Message: qeth: avoid buffer overflow in snmp ioctl
Check user-defined length in snmp ioctl request and allow request
only if it fits into a qeth command buffer.
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Reviewed-by: Heiko Carstens <heicars2@linux.vnet.ibm.com>
Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-119
| 0
| 3,472
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int posix_cpu_nsleep(const clockid_t which_clock, int flags,
struct timespec *rqtp, struct timespec __user *rmtp)
{
struct restart_block *restart_block =
¤t_thread_info()->restart_block;
struct itimerspec it;
int error;
/*
* Diagnose required errors first.
*/
if (CPUCLOCK_PERTHREAD(which_clock) &&
(CPUCLOCK_PID(which_clock) == 0 ||
CPUCLOCK_PID(which_clock) == current->pid))
return -EINVAL;
error = do_cpu_nanosleep(which_clock, flags, rqtp, &it);
if (error == -ERESTART_RESTARTBLOCK) {
if (flags & TIMER_ABSTIME)
return -ERESTARTNOHAND;
/*
* Report back to the user the time still remaining.
*/
if (rmtp != NULL && copy_to_user(rmtp, &it.it_value, sizeof *rmtp))
return -EFAULT;
restart_block->fn = posix_cpu_nsleep_restart;
restart_block->arg0 = which_clock;
restart_block->arg1 = (unsigned long) rmtp;
restart_block->arg2 = rqtp->tv_sec;
restart_block->arg3 = rqtp->tv_nsec;
}
return error;
}
Commit Message: remove div_long_long_rem
x86 is the only arch right now, which provides an optimized for
div_long_long_rem and it has the downside that one has to be very careful that
the divide doesn't overflow.
The API is a little akward, as the arguments for the unsigned divide are
signed. The signed version also doesn't handle a negative divisor and
produces worse code on 64bit archs.
There is little incentive to keep this API alive, so this converts the few
users to the new API.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-189
| 0
| 27,149
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() {
if (!web_user_media_client_)
InitializeUserMediaClient();
return web_user_media_client_ ?
web_user_media_client_->media_stream_dispatcher() : NULL;
}
Commit Message: Connect WebUSB client interface to the devices app
This provides a basic WebUSB client interface in
content/renderer. Most of the interface is unimplemented,
but this CL hooks up navigator.usb.getDevices() to the
browser's Mojo devices app to enumerate available USB
devices.
BUG=492204
Review URL: https://codereview.chromium.org/1293253002
Cr-Commit-Position: refs/heads/master@{#344881}
CWE ID: CWE-399
| 0
| 24,152
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,
int *ret, struct net_device *orig_dev)
{
#ifdef CONFIG_NETFILTER_INGRESS
if (nf_hook_ingress_active(skb)) {
int ingress_retval;
if (*pt_prev) {
*ret = deliver_skb(skb, *pt_prev, orig_dev);
*pt_prev = NULL;
}
rcu_read_lock();
ingress_retval = nf_hook_ingress(skb);
rcu_read_unlock();
return ingress_retval;
}
#endif /* CONFIG_NETFILTER_INGRESS */
return 0;
}
Commit Message: tun: call dev_get_valid_name() before register_netdevice()
register_netdevice() could fail early when we have an invalid
dev name, in which case ->ndo_uninit() is not called. For tun
device, this is a problem because a timer etc. are already
initialized and it expects ->ndo_uninit() to clean them up.
We could move these initializations into a ->ndo_init() so
that register_netdevice() knows better, however this is still
complicated due to the logic in tun_detach().
Therefore, I choose to just call dev_get_valid_name() before
register_netdevice(), which is quicker and much easier to audit.
And for this specific case, it is already enough.
Fixes: 96442e42429e ("tuntap: choose the txq based on rxq")
Reported-by: Dmitry Alexeev <avekceeb@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-476
| 0
| 4,564
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int proc_attr_dir_readdir(struct file * filp,
void * dirent, filldir_t filldir)
{
return proc_pident_readdir(filp,dirent,filldir,
attr_dir_stuff,ARRAY_SIZE(attr_dir_stuff));
}
Commit Message: proc: restrict access to /proc/PID/io
/proc/PID/io may be used for gathering private information. E.g. for
openssh and vsftpd daemons wchars/rchars may be used to learn the
precise password length. Restrict it to processes being able to ptrace
the target process.
ptrace_may_access() is needed to prevent keeping open file descriptor of
"io" file, executing setuid binary and gathering io information of the
setuid'ed process.
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-264
| 0
| 27,363
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void BackendIO::DoomEntriesSince(const base::Time initial_time) {
operation_ = OP_DOOM_SINCE;
initial_time_ = initial_time;
}
Commit Message: Blockfile cache: fix long-standing sparse + evict reentrancy problem
Thanks to nedwilliamson@ (on gmail) for an alternative perspective
plus a reduction to make fixing this much easier.
Bug: 826626, 518908, 537063, 802886
Change-Id: Ibfa01416f9a8e7f7b361e4f93b4b6b134728b85f
Reviewed-on: https://chromium-review.googlesource.com/985052
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547103}
CWE ID: CWE-20
| 0
| 19,112
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: _gnutls_set_client_random (gnutls_session_t session, uint8_t * rnd)
{
memcpy (session->security_parameters.client_random, rnd, TLS_RANDOM_SIZE);
}
Commit Message:
CWE ID: CWE-189
| 0
| 6,779
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: json_t *json_string(const char *value)
{
if(!value || !utf8_check_string(value, -1))
return NULL;
return json_string_nocheck(value);
}
Commit Message: CVE-2013-6401: Change hash function, randomize hashes
Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing
and testing.
CWE ID: CWE-310
| 0
| 3,262
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: ImageData* WebGLRenderingContextBase::ToImageData(SnapshotReason reason) {
ImageData* image_data = nullptr;
if (GetDrawingBuffer()) {
image_data = PaintRenderingResultsToImageData(kBackBuffer);
if (image_data) {
return image_data;
}
int width = GetDrawingBuffer()->Size().Width();
int height = GetDrawingBuffer()->Size().Height();
SkImageInfo image_info =
SkImageInfo::Make(width, height, kRGBA_8888_SkColorType,
CreationAttributes().alpha() ? kPremul_SkAlphaType
: kOpaque_SkAlphaType);
sk_sp<SkImage> snapshot = MakeImageSnapshot(image_info);
if (snapshot) {
image_data = ImageData::Create(GetDrawingBuffer()->Size());
snapshot->readPixels(image_info, image_data->data()->Data(),
image_info.minRowBytes(), 0, 0);
}
}
return image_data;
}
Commit Message: Reset ES3 pixel pack parameters and PIXEL_PACK_BUFFER binding in DrawingBuffer before ReadPixels() and recover them later.
BUG=740603
TEST=new conformance test
R=kbr@chromium.org,piman@chromium.org
Change-Id: I3ea54c6cc34f34e249f7c8b9f792d93c5e1958f4
Reviewed-on: https://chromium-review.googlesource.com/570840
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486518}
CWE ID: CWE-119
| 0
| 10,354
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void GLES2Implementation::CompressedTexImage3D(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLsizei image_size,
const void* data) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG(
"[" << GetLogPrefix() << "] glCompressedTexImage3D("
<< GLES2Util::GetStringTexture3DTarget(target) << ", " << level
<< ", " << GLES2Util::GetStringCompressedTextureFormat(internalformat)
<< ", " << width << ", " << height << ", " << depth << ", " << border
<< ", " << image_size << ", " << static_cast<const void*>(data)
<< ")");
if (width < 0 || height < 0 || depth < 0 || level < 0) {
SetGLError(GL_INVALID_VALUE, "glCompressedTexImage3D", "dimension < 0");
return;
}
if (border != 0) {
SetGLError(GL_INVALID_VALUE, "glCompressedTexImage3D", "border != 0");
return;
}
if (bound_pixel_unpack_transfer_buffer_id_) {
GLuint offset = ToGLuint(data);
BufferTracker::Buffer* buffer = GetBoundPixelTransferBufferIfValid(
bound_pixel_unpack_transfer_buffer_id_, "glCompressedTexImage3D",
offset, image_size);
if (buffer && buffer->shm_id() != -1) {
helper_->CompressedTexImage3D(target, level, internalformat, width,
height, depth, image_size, buffer->shm_id(),
buffer->shm_offset() + offset);
buffer->set_last_usage_token(helper_->InsertToken());
}
return;
}
if (bound_pixel_unpack_buffer_) {
helper_->CompressedTexImage3D(target, level, internalformat, width, height,
depth, image_size, 0, ToGLuint(data));
} else if (data) {
SetBucketContents(kResultBucketId, data, image_size);
helper_->CompressedTexImage3DBucket(target, level, internalformat, width,
height, depth, kResultBucketId);
helper_->SetBucketSize(kResultBucketId, 0);
} else {
helper_->CompressedTexImage3D(target, level, internalformat, width, height,
depth, image_size, 0, 0);
}
CheckGLError();
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416
| 0
| 2,228
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void PageInfo::OnChangePasswordButtonPressed(
content::WebContents* web_contents) {
#if defined(FULL_SAFE_BROWSING)
DCHECK(password_protection_service_);
DCHECK(safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE ||
safe_browsing_status_ ==
SAFE_BROWSING_STATUS_ENTERPRISE_PASSWORD_REUSE);
password_protection_service_->OnUserAction(
web_contents,
safe_browsing_status_ == SAFE_BROWSING_STATUS_SIGN_IN_PASSWORD_REUSE
? PasswordReuseEvent::SIGN_IN_PASSWORD
: PasswordReuseEvent::ENTERPRISE_PASSWORD,
safe_browsing::WarningUIType::PAGE_INFO,
safe_browsing::WarningAction::CHANGE_PASSWORD);
#endif
}
Commit Message: Revert "PageInfo: decouple safe browsing and TLS statii."
This reverts commit ee95bc44021230127c7e6e9a8cf9d3820760f77c.
Reason for revert: suspect causing unit_tests failure on Linux MSAN Tests:
https://ci.chromium.org/p/chromium/builders/ci/Linux%20MSan%20Tests/17649
PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered
PageInfoBubbleViewTest.EnsureCloseCallback
PageInfoBubbleViewTest.NotificationPermissionRevokeUkm
PageInfoBubbleViewTest.OpenPageInfoBubbleAfterNavigationStart
PageInfoBubbleViewTest.SetPermissionInfo
PageInfoBubbleViewTest.SetPermissionInfoForUsbGuard
PageInfoBubbleViewTest.SetPermissionInfoWithPolicyUsbDevices
PageInfoBubbleViewTest.SetPermissionInfoWithUsbDevice
PageInfoBubbleViewTest.SetPermissionInfoWithUserAndPolicyUsbDevices
PageInfoBubbleViewTest.UpdatingSiteDataRetainsLayout
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8909718923797040064/+/steps/unit_tests/0/logs/Deterministic_failure:_PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered__status_CRASH_/0
[ RUN ] PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered
==9056==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x561baaab15ec in PageInfoUI::GetSecurityDescription(PageInfoUI::IdentityInfo const&) const ./../../chrome/browser/ui/page_info/page_info_ui.cc:250:3
#1 0x561bab6a1548 in PageInfoBubbleView::SetIdentityInfo(PageInfoUI::IdentityInfo const&) ./../../chrome/browser/ui/views/page_info/page_info_bubble_view.cc:802:7
#2 0x561baaaab3bb in PageInfo::PresentSiteIdentity() ./../../chrome/browser/ui/page_info/page_info.cc:969:8
#3 0x561baaaa0a21 in PageInfo::PageInfo(PageInfoUI*, Profile*, TabSpecificContentSettings*, content::WebContents*, GURL const&, security_state::SecurityLevel, security_state::VisibleSecurityState const&) ./../../chrome/browser/ui/page_info/page_info.cc:344:3
#4 0x561bab69b6dd in PageInfoBubbleView::PageInfoBubbleView(views::View*, gfx::Rect const&, aura::Window*, Profile*, content::WebContents*, GURL const&, security_state::SecurityLevel, security_state::VisibleSecurityState const&, base::OnceCallback<void (views::Widget::ClosedReason, bool)>) ./../../chrome/browser/ui/views/page_info/page_info_bubble_view.cc:576:24
...
Original change's description:
> PageInfo: decouple safe browsing and TLS statii.
>
> Previously, the Page Info bubble maintained a single variable to
> identify all reasons that a page might have a non-standard status. This
> lead to the display logic making assumptions about, for instance, the
> validity of a certificate when the page was flagged by Safe Browsing.
>
> This CL separates out the Safe Browsing status from the site identity
> status so that the page info bubble can inform the user that the site's
> certificate is invalid, even if it's also flagged by Safe Browsing.
>
> Bug: 869925
> Change-Id: I34107225b4206c8f32771ccd75e9367668d0a72b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1662537
> Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
> Reviewed-by: Bret Sepulveda <bsep@chromium.org>
> Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org>
> Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#671847}
TBR=meacer@chromium.org,bsep@chromium.org,jdeblasio@chromium.org
Change-Id: I8be652952e7276bcc9266124693352e467159cc4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 869925
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1673985
Reviewed-by: Takashi Sakamoto <tasak@google.com>
Commit-Queue: Takashi Sakamoto <tasak@google.com>
Cr-Commit-Position: refs/heads/master@{#671932}
CWE ID: CWE-311
| 1
| 8,540
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool CanonicalizeUserInfo(const base::char16* username_source,
const Component& username,
const base::char16* password_source,
const Component& password,
CanonOutput* output,
Component* out_username,
Component* out_password) {
return DoUserInfo<base::char16, base::char16>(
username_source, username, password_source, password,
output, out_username, out_password);
}
Commit Message: Percent-encode UTF8 characters in URL fragment identifiers.
This brings us into line with Firefox, Safari, and the spec.
Bug: 758523
Change-Id: I7e354ab441222d9fd08e45f0e70f91ad4e35fafe
Reviewed-on: https://chromium-review.googlesource.com/668363
Commit-Queue: Mike West <mkwst@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Andy Paicu <andypaicu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507481}
CWE ID: CWE-79
| 0
| 15,392
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int sas_ex_revalidate_domain(struct domain_device *port_dev)
{
int res;
struct domain_device *dev = NULL;
res = sas_find_bcast_dev(port_dev, &dev);
if (res == 0 && dev) {
struct expander_device *ex = &dev->ex_dev;
int i = 0, phy_id;
do {
phy_id = -1;
res = sas_find_bcast_phy(dev, &phy_id, i, true);
if (phy_id == -1)
break;
res = sas_rediscover(dev, phy_id);
i = phy_id + 1;
} while (i < ex->num_phys);
}
return res;
}
Commit Message: scsi: libsas: fix a race condition when smp task timeout
When the lldd is processing the complete sas task in interrupt and set the
task stat as SAS_TASK_STATE_DONE, the smp timeout timer is able to be
triggered at the same time. And smp_task_timedout() will complete the task
wheter the SAS_TASK_STATE_DONE is set or not. Then the sas task may freed
before lldd end the interrupt process. Thus a use-after-free will happen.
Fix this by calling the complete() only when SAS_TASK_STATE_DONE is not
set. And remove the check of the return value of the del_timer(). Once the
LLDD sets DONE, it must call task->done(), which will call
smp_task_done()->complete() and the task will be completed and freed
correctly.
Reported-by: chenxiang <chenxiang66@hisilicon.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: Johannes Thumshirn <jthumshirn@suse.de>
CC: Ewan Milne <emilne@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Tomas Henzl <thenzl@redhat.com>
CC: Dan Williams <dan.j.williams@intel.com>
CC: Hannes Reinecke <hare@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
CWE ID: CWE-416
| 0
| 13,578
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
unsigned int idx)
{
__free_page(spd->pages[idx]);
}
Commit Message: Merge tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt:
"This contains a few fixes and a clean up.
- a bad merge caused an "endif" to go in the wrong place in
scripts/Makefile.build
- softirq tracing fix for tracing that corrupts lockdep and causes a
false splat
- histogram documentation typo fixes
- fix a bad memory reference when passing in no filter to the filter
code
- simplify code by using the swap macro instead of open coding the
swap"
* tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount
tracing: Fix some errors in histogram documentation
tracing: Use swap macro in update_max_tr
softirq: Reorder trace_softirqs_on to prevent lockdep splat
tracing: Check for no filter when processing event filters
CWE ID: CWE-787
| 0
| 25,527
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RunUntilIdle() {
loop_.RunUntilIdle();
BrowserThread::GetBlockingPool()->FlushForTesting();
loop_.RunUntilIdle();
}
Commit Message: Make the policy fetch for first time login blocking
The CL makes policy fetching for first time login blocking for all users, except the ones that are known to be non-enterprise users.
BUG=334584
Review URL: https://codereview.chromium.org/330843002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282925 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119
| 0
| 13,398
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);
u64 cr8;
if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK))
return;
cr8 = kvm_get_cr8(vcpu);
svm->vmcb->control.int_ctl &= ~V_TPR_MASK;
svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK;
}
Commit Message: KVM: x86: Check non-canonical addresses upon WRMSR
Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is
written to certain MSRs. The behavior is "almost" identical for AMD and Intel
(ignoring MSRs that are not implemented in either architecture since they would
anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if
non-canonical address is written on Intel but not on AMD (which ignores the top
32-bits).
Accordingly, this patch injects a #GP on the MSRs which behave identically on
Intel and AMD. To eliminate the differences between the architecutres, the
value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to
canonical value before writing instead of injecting a #GP.
Some references from Intel and AMD manuals:
According to Intel SDM description of WRMSR instruction #GP is expected on
WRMSR "If the source register contains a non-canonical address and ECX
specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE,
IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP."
According to AMD manual instruction manual:
LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the
LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical
form, a general-protection exception (#GP) occurs."
IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the
base field must be in canonical form or a #GP fault will occur."
IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must
be in canonical form."
This patch fixes CVE-2014-3610.
Cc: stable@vger.kernel.org
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-264
| 0
| 25,404
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: FileTransfer::CommitFiles()
{
MyString buf;
MyString newbuf;
MyString swapbuf;
const char *file;
if ( IsClient() ) {
return;
}
int cluster = -1;
int proc = -1;
jobAd.LookupInteger(ATTR_CLUSTER_ID, cluster);
jobAd.LookupInteger(ATTR_PROC_ID, proc);
priv_state saved_priv = PRIV_UNKNOWN;
if( want_priv_change ) {
saved_priv = set_priv( desired_priv_state );
}
Directory tmpspool( TmpSpoolSpace, desired_priv_state );
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,COMMIT_FILENAME);
if ( access(buf.Value(),F_OK) >= 0 ) {
MyString SwapSpoolSpace;
SwapSpoolSpace.sprintf("%s.swap",SpoolSpace);
bool swap_dir_ready = SpooledJobFiles::createJobSwapSpoolDirectory(&jobAd,desired_priv_state);
if( !swap_dir_ready ) {
EXCEPT("Failed to create %s",SwapSpoolSpace.Value());
}
while ( (file=tmpspool.Next()) ) {
if ( file_strcmp(file,COMMIT_FILENAME) == MATCH )
continue;
buf.sprintf("%s%c%s",TmpSpoolSpace,DIR_DELIM_CHAR,file);
newbuf.sprintf("%s%c%s",SpoolSpace,DIR_DELIM_CHAR,file);
swapbuf.sprintf("%s%c%s",SwapSpoolSpace.Value(),DIR_DELIM_CHAR,file);
if( access(newbuf.Value(),F_OK) >= 0 ) {
if ( rename(newbuf.Value(),swapbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles failed to move %s to %s: %s",newbuf.Value(),swapbuf.Value(),strerror(errno));
}
}
if ( rotate_file(buf.Value(),newbuf.Value()) < 0 ) {
EXCEPT("FileTransfer CommitFiles Failed -- What Now?!?!");
}
}
SpooledJobFiles::removeJobSwapSpoolDirectory(cluster,proc);
}
tmpspool.Remove_Entire_Directory();
if( want_priv_change ) {
ASSERT( saved_priv != PRIV_UNKNOWN );
set_priv( saved_priv );
}
}
Commit Message:
CWE ID: CWE-134
| 0
| 823
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int ubifs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
{
struct inode *inode = mapping->host;
struct ubifs_info *c = inode->i_sb->s_fs_info;
struct ubifs_inode *ui = ubifs_inode(inode);
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
int skipped_read = 0;
struct page *page;
ubifs_assert(ubifs_inode(inode)->ui_size == inode->i_size);
ubifs_assert(!c->ro_media && !c->ro_mount);
if (unlikely(c->ro_error))
return -EROFS;
/* Try out the fast-path part first */
page = grab_cache_page_write_begin(mapping, index, flags);
if (unlikely(!page))
return -ENOMEM;
if (!PageUptodate(page)) {
/* The page is not loaded from the flash */
if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) {
/*
* We change whole page so no need to load it. But we
* do not know whether this page exists on the media or
* not, so we assume the latter because it requires
* larger budget. The assumption is that it is better
* to budget a bit more than to read the page from the
* media. Thus, we are setting the @PG_checked flag
* here.
*/
SetPageChecked(page);
skipped_read = 1;
} else {
err = do_readpage(page);
if (err) {
unlock_page(page);
page_cache_release(page);
return err;
}
}
SetPageUptodate(page);
ClearPageError(page);
}
err = allocate_budget(c, page, ui, appending);
if (unlikely(err)) {
ubifs_assert(err == -ENOSPC);
/*
* If we skipped reading the page because we were going to
* write all of it, then it is not up to date.
*/
if (skipped_read) {
ClearPageChecked(page);
ClearPageUptodate(page);
}
/*
* Budgeting failed which means it would have to force
* write-back but didn't, because we set the @fast flag in the
* request. Write-back cannot be done now, while we have the
* page locked, because it would deadlock. Unlock and free
* everything and fall-back to slow-path.
*/
if (appending) {
ubifs_assert(mutex_is_locked(&ui->ui_mutex));
mutex_unlock(&ui->ui_mutex);
}
unlock_page(page);
page_cache_release(page);
return write_begin_slow(mapping, pos, len, pagep, flags);
}
/*
* Whee, we acquired budgeting quickly - without involving
* garbage-collection, committing or forcing write-back. We return
* with @ui->ui_mutex locked if we are appending pages, and unlocked
* otherwise. This is an optimization (slightly hacky though).
*/
*pagep = page;
return 0;
}
Commit Message: ->splice_write() via ->write_iter()
iter_file_splice_write() - a ->splice_write() instance that gathers the
pipe buffers, builds a bio_vec-based iov_iter covering those and feeds
it to ->write_iter(). A bunch of simple cases coverted to that...
[AV: fixed the braino spotted by Cyrill]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
CWE ID: CWE-264
| 0
| 3,272
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void GLES2Implementation::GetProgramResourceName(GLuint program,
GLenum program_interface,
GLuint index,
GLsizei bufsize,
GLsizei* length,
char* name) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetProgramResourceName("
<< program << ", " << program_interface << ", " << index
<< ", " << bufsize << ", " << static_cast<void*>(length)
<< ", " << static_cast<void*>(name) << ")");
if (bufsize < 0) {
SetGLError(GL_INVALID_VALUE, "glGetProgramResourceName", "bufsize < 0");
return;
}
TRACE_EVENT0("gpu", "GLES2::GetProgramResourceName");
bool success = share_group_->program_info_manager()->GetProgramResourceName(
this, program, program_interface, index, bufsize, length, name);
if (success && name) {
GPU_CLIENT_LOG(" name: " << name);
}
CheckGLError();
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416
| 0
| 5,892
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void VerifyRemoveFromCache(base::PlatformFileError error,
const std::string& resource_id,
const std::string& md5) {
++num_callback_invocations_;
EXPECT_EQ(expected_error_, error);
GDataRootDirectory::CacheEntry* entry =
file_system_->root_->GetCacheEntry(resource_id, md5);
if (entry)
EXPECT_TRUE(entry->IsDirty());
std::vector<PathToVerify> paths_to_verify;
paths_to_verify.push_back( // Index 0: CACHE_TYPE_TMP.
PathToVerify(file_system_->GetCacheFilePath(resource_id, "*",
GDataRootDirectory::CACHE_TYPE_TMP,
GDataFileSystem::CACHED_FILE_FROM_SERVER), FilePath()));
paths_to_verify.push_back( // Index 1: CACHE_TYPE_PERSISTENT.
PathToVerify(file_system_->GetCacheFilePath(resource_id, "*",
GDataRootDirectory::CACHE_TYPE_PERSISTENT,
GDataFileSystem::CACHED_FILE_FROM_SERVER), FilePath()));
paths_to_verify.push_back( // Index 2: CACHE_TYPE_PINNED.
PathToVerify(file_system_->GetCacheFilePath(resource_id, "",
GDataRootDirectory::CACHE_TYPE_PINNED,
GDataFileSystem::CACHED_FILE_FROM_SERVER), FilePath()));
paths_to_verify.push_back( // Index 3: CACHE_TYPE_OUTGOING.
PathToVerify(file_system_->GetCacheFilePath(resource_id, "",
GDataRootDirectory::CACHE_TYPE_OUTGOING,
GDataFileSystem::CACHED_FILE_FROM_SERVER), FilePath()));
if (!entry) {
for (size_t i = 0; i < paths_to_verify.size(); ++i) {
file_util::FileEnumerator enumerator(
paths_to_verify[i].path_to_scan.DirName(), false /* not recursive*/,
static_cast<file_util::FileEnumerator::FileType>(
file_util::FileEnumerator::FILES |
file_util::FileEnumerator::SHOW_SYM_LINKS),
paths_to_verify[i].path_to_scan.BaseName().value());
EXPECT_TRUE(enumerator.Next().empty());
}
} else {
paths_to_verify[1].expected_existing_path =
GetCacheFilePath(resource_id,
std::string(),
GDataRootDirectory::CACHE_TYPE_PERSISTENT,
GDataFileSystem::CACHED_FILE_LOCALLY_MODIFIED);
paths_to_verify[3].expected_existing_path =
GetCacheFilePath(resource_id,
std::string(),
GDataRootDirectory::CACHE_TYPE_OUTGOING,
GDataFileSystem::CACHED_FILE_FROM_SERVER);
if (entry->IsPinned()) {
paths_to_verify[2].expected_existing_path =
GetCacheFilePath(resource_id,
std::string(),
GDataRootDirectory::CACHE_TYPE_PINNED,
GDataFileSystem::CACHED_FILE_FROM_SERVER);
}
for (size_t i = 0; i < paths_to_verify.size(); ++i) {
const struct PathToVerify& verify = paths_to_verify[i];
file_util::FileEnumerator enumerator(
verify.path_to_scan.DirName(), false /* not recursive*/,
static_cast<file_util::FileEnumerator::FileType>(
file_util::FileEnumerator::FILES |
file_util::FileEnumerator::SHOW_SYM_LINKS),
verify.path_to_scan.BaseName().value());
size_t num_files_found = 0;
for (FilePath current = enumerator.Next(); !current.empty();
current = enumerator.Next()) {
++num_files_found;
EXPECT_EQ(verify.expected_existing_path, current);
}
if (verify.expected_existing_path.empty())
EXPECT_EQ(0U, num_files_found);
else
EXPECT_EQ(1U, num_files_found);
}
}
}
Commit Message: gdata: Define the resource ID for the root directory
Per the spec, the resource ID for the root directory is defined
as "folder:root". Add the resource ID to the root directory in our
file system representation so we can look up the root directory by
the resource ID.
BUG=127697
TEST=add unit tests
Review URL: https://chromiumcodereview.appspot.com/10332253
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137928 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 25,675
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void HTMLFormControlElement::requiredAttributeChanged() {
setNeedsValidityCheck();
pseudoStateChanged(CSSSelector::PseudoRequired);
pseudoStateChanged(CSSSelector::PseudoOptional);
}
Commit Message: Form validation: Do not show validation bubble if the page is invisible.
BUG=673163
Review-Url: https://codereview.chromium.org/2572813003
Cr-Commit-Position: refs/heads/master@{#438476}
CWE ID: CWE-1021
| 0
| 22,492
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderFrameImpl::MarkWebAXObjectDirty(const blink::WebAXObject& obj,
bool subtree) {
if (render_accessibility_)
render_accessibility_->MarkWebAXObjectDirty(obj, subtree);
}
Commit Message: Convert FrameHostMsg_DidAddMessageToConsole to Mojo.
Note: Since this required changing the test
RenderViewImplTest.DispatchBeforeUnloadCanDetachFrame, I manually
re-introduced https://crbug.com/666714 locally (the bug the test was
added for), and reran the test to confirm that it still covers the bug.
Bug: 786836
Change-Id: I110668fa6f0f261fd2ac36bb91a8d8b31c99f4f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526270
Commit-Queue: Lowell Manners <lowell@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653137}
CWE ID: CWE-416
| 0
| 20,806
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void NuPlayer::GenericSource::sendTextData(
uint32_t what,
media_track_type type,
int32_t curGen,
sp<AnotherPacketSource> packets,
sp<AMessage> msg) {
int32_t msgGeneration;
CHECK(msg->findInt32("generation", &msgGeneration));
if (msgGeneration != curGen) {
return;
}
int64_t subTimeUs;
if (packets->nextBufferTime(&subTimeUs) != OK) {
return;
}
int64_t nextSubTimeUs;
readBuffer(type, -1, &nextSubTimeUs);
sp<ABuffer> buffer;
status_t dequeueStatus = packets->dequeueAccessUnit(&buffer);
if (dequeueStatus == OK) {
sp<AMessage> notify = dupNotify();
notify->setInt32("what", what);
notify->setBuffer("buffer", buffer);
notify->post();
const int64_t delayUs = nextSubTimeUs - subTimeUs;
msg->post(delayUs < 0 ? 0 : delayUs);
}
}
Commit Message: MPEG4Extractor: ensure kKeyTrackID exists before creating an MPEG4Source as track.
GenericSource: return error when no track exists.
SampleIterator: make sure mSamplesPerChunk is not zero before using it as divisor.
Bug: 21657957
Bug: 23705695
Bug: 22802344
Bug: 28799341
Change-Id: I7664992ade90b935d3f255dcd43ecc2898f30b04
(cherry picked from commit 0386c91b8a910a134e5898ffa924c1b6c7560b13)
CWE ID: CWE-119
| 0
| 3,095
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void license_read_upgrade_license_packet(rdpLicense* license, wStream* s)
{
DEBUG_LICENSE("Receiving Upgrade License Packet");
license->state = LICENSE_STATE_COMPLETED;
}
Commit Message: Fix possible integer overflow in license_read_scope_list()
CWE ID: CWE-189
| 0
| 4,699
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool HTMLSelectElement::platformHandleKeydownEvent(KeyboardEvent* event)
{
if (!RenderTheme::theme().popsMenuByArrowKeys())
return false;
if (!isSpatialNavigationEnabled(document().frame())) {
if (event->keyIdentifier() == "Down" || event->keyIdentifier() == "Up") {
focus();
if (!renderer())
return true;
saveLastSelection();
if (RenderMenuList* menuList = toRenderMenuList(renderer()))
menuList->showPopup();
event->setDefaultHandled();
}
return true;
}
return false;
}
Commit Message: Add HTMLFormControlElement::supportsAutofocus to fix a FIXME comment.
This virtual function should return true if the form control can hanlde
'autofocucs' attribute if it is specified.
Note: HTMLInputElement::supportsAutofocus reuses InputType::isInteractiveContent
because interactiveness is required for autofocus capability.
BUG=none
TEST=none; no behavior changes.
Review URL: https://codereview.chromium.org/143343003
git-svn-id: svn://svn.chromium.org/blink/trunk@165432 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119
| 0
| 6,855
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void DevToolsDataSource::StartBundledDataRequest(
const std::string& path,
const content::URLDataSource::GotDataCallback& callback) {
std::string filename = PathWithoutParams(path);
base::StringPiece resource =
content::DevToolsFrontendHost::GetFrontendResource(filename);
DLOG_IF(WARNING, resource.empty())
<< "Unable to find dev tool resource: " << filename
<< ". If you compiled with debug_devtools=1, try running with "
"--debug-devtools.";
scoped_refptr<base::RefCountedStaticMemory> bytes(
new base::RefCountedStaticMemory(resource.data(), resource.length()));
callback.Run(bytes.get());
}
Commit Message: DevTools: move front-end URL handling to DevToolsUIBindingds
BUG=662859
Review-Url: https://codereview.chromium.org/2607833002
Cr-Commit-Position: refs/heads/master@{#440926}
CWE ID: CWE-200
| 0
| 7,307
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool DateTimeFieldElement::isDateTimeFieldElement() const
{
return true;
}
Commit Message: INPUT_MULTIPLE_FIELDS_UI: Inconsistent value of aria-valuetext attribute
https://bugs.webkit.org/show_bug.cgi?id=107897
Reviewed by Kentaro Hara.
Source/WebCore:
aria-valuetext and aria-valuenow attributes had inconsistent values in
a case of initial empty state and a case that a user clears a field.
- aria-valuetext attribute should have "blank" message in the initial
empty state.
- aria-valuenow attribute should be removed in the cleared empty state.
Also, we have a bug that aira-valuenow had a symbolic value such as "AM"
"January". It should always have a numeric value according to the
specification.
http://www.w3.org/TR/wai-aria/states_and_properties#aria-valuenow
No new tests. Updates fast/forms/*-multiple-fields/*-multiple-fields-ax-aria-attributes.html.
* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
Set "blank" message to aria-valuetext attribute.
(WebCore::DateTimeFieldElement::updateVisibleValue):
aria-valuenow attribute should be a numeric value. Apply String::number
to the return value of valueForARIAValueNow.
Remove aria-valuenow attribute if nothing is selected.
(WebCore::DateTimeFieldElement::valueForARIAValueNow):
Added.
* html/shadow/DateTimeFieldElement.h:
(DateTimeFieldElement): Declare valueForARIAValueNow.
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::valueForARIAValueNow):
Added. Returns 1 + internal selection index.
For example, the function returns 1 for January.
* html/shadow/DateTimeSymbolicFieldElement.h:
(DateTimeSymbolicFieldElement): Declare valueForARIAValueNow.
LayoutTests:
Fix existing tests to show aria-valuenow attribute values.
* fast/forms/resources/multiple-fields-ax-aria-attributes.js: Added.
* fast/forms/date-multiple-fields/date-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/date-multiple-fields/date-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
Add tests for initial empty-value state.
* fast/forms/month-multiple-fields/month-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/month-multiple-fields/month-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
git-svn-id: svn://svn.chromium.org/blink/trunk@140803 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119
| 0
| 26,414
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: string16 GetFindBarMatchCountTextForBrowser(Browser* browser) {
FindBarTesting* find_bar =
browser->GetFindBarController()->find_bar()->GetFindBarTesting();
return find_bar->GetMatchCountText();
}
Commit Message: Rename the TabContentWrapper pieces to be "TabHelper"s. (Except for the PasswordManager... for now.) Also, just pre-create them up-front. It saves us effort, as they're all going to be eventually created anyway, so being lazy saves us nothing and creates headaches since the rules about what can be lazy differ from feature to feature.
BUG=71097
TEST=zero visible change
Review URL: http://codereview.chromium.org/6480117
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75170 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20
| 0
| 19,552
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int snd_interval_ratnum(struct snd_interval *i,
unsigned int rats_count, const struct snd_ratnum *rats,
unsigned int *nump, unsigned int *denp)
{
unsigned int best_num, best_den;
int best_diff;
unsigned int k;
struct snd_interval t;
int err;
unsigned int result_num, result_den;
int result_diff;
best_num = best_den = best_diff = 0;
for (k = 0; k < rats_count; ++k) {
unsigned int num = rats[k].num;
unsigned int den;
unsigned int q = i->min;
int diff;
if (q == 0)
q = 1;
den = div_up(num, q);
if (den < rats[k].den_min)
continue;
if (den > rats[k].den_max)
den = rats[k].den_max;
else {
unsigned int r;
r = (den - rats[k].den_min) % rats[k].den_step;
if (r != 0)
den -= r;
}
diff = num - q * den;
if (diff < 0)
diff = -diff;
if (best_num == 0 ||
diff * best_den < best_diff * den) {
best_diff = diff;
best_den = den;
best_num = num;
}
}
if (best_den == 0) {
i->empty = 1;
return -EINVAL;
}
t.min = div_down(best_num, best_den);
t.openmin = !!(best_num % best_den);
result_num = best_num;
result_diff = best_diff;
result_den = best_den;
best_num = best_den = best_diff = 0;
for (k = 0; k < rats_count; ++k) {
unsigned int num = rats[k].num;
unsigned int den;
unsigned int q = i->max;
int diff;
if (q == 0) {
i->empty = 1;
return -EINVAL;
}
den = div_down(num, q);
if (den > rats[k].den_max)
continue;
if (den < rats[k].den_min)
den = rats[k].den_min;
else {
unsigned int r;
r = (den - rats[k].den_min) % rats[k].den_step;
if (r != 0)
den += rats[k].den_step - r;
}
diff = q * den - num;
if (diff < 0)
diff = -diff;
if (best_num == 0 ||
diff * best_den < best_diff * den) {
best_diff = diff;
best_den = den;
best_num = num;
}
}
if (best_den == 0) {
i->empty = 1;
return -EINVAL;
}
t.max = div_up(best_num, best_den);
t.openmax = !!(best_num % best_den);
t.integer = 0;
err = snd_interval_refine(i, &t);
if (err < 0)
return err;
if (snd_interval_single(i)) {
if (best_diff * result_den < result_diff * best_den) {
result_num = best_num;
result_den = best_den;
}
if (nump)
*nump = result_num;
if (denp)
*denp = result_den;
}
return err;
}
Commit Message: ALSA: pcm : Call kill_fasync() in stream lock
Currently kill_fasync() is called outside the stream lock in
snd_pcm_period_elapsed(). This is potentially racy, since the stream
may get released even during the irq handler is running. Although
snd_pcm_release_substream() calls snd_pcm_drop(), this doesn't
guarantee that the irq handler finishes, thus the kill_fasync() call
outside the stream spin lock may be invoked after the substream is
detached, as recently reported by KASAN.
As a quick workaround, move kill_fasync() call inside the stream
lock. The fasync is rarely used interface, so this shouldn't have a
big impact from the performance POV.
Ideally, we should implement some sync mechanism for the proper finish
of stream and irq handler. But this oneliner should suffice for most
cases, so far.
Reported-by: Baozeng Ding <sploving1@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CWE ID: CWE-416
| 0
| 29,957
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
: RenderWidget(WebKit::WebPopupTypeNone,
params->screen_info,
params->swapped_out),
webkit_preferences_(params->webkit_prefs),
send_content_state_immediately_(false),
enabled_bindings_(0),
send_preferred_size_changes_(false),
is_loading_(false),
navigation_gesture_(NavigationGestureUnknown),
opened_by_user_gesture_(true),
opener_suppressed_(false),
page_id_(-1),
last_page_id_sent_to_browser_(-1),
next_page_id_(params->next_page_id),
history_list_offset_(-1),
history_list_length_(0),
target_url_status_(TARGET_NONE),
selection_text_offset_(0),
cached_is_main_frame_pinned_to_left_(false),
cached_is_main_frame_pinned_to_right_(false),
cached_has_main_frame_horizontal_scrollbar_(false),
cached_has_main_frame_vertical_scrollbar_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
geolocation_dispatcher_(NULL),
input_tag_speech_dispatcher_(NULL),
speech_recognition_dispatcher_(NULL),
device_orientation_dispatcher_(NULL),
media_stream_dispatcher_(NULL),
browser_plugin_manager_(NULL),
media_stream_impl_(NULL),
devtools_agent_(NULL),
accessibility_mode_(AccessibilityModeOff),
renderer_accessibility_(NULL),
java_bridge_dispatcher_(NULL),
mouse_lock_dispatcher_(NULL),
favicon_helper_(NULL),
#if defined(OS_ANDROID)
body_background_color_(SK_ColorWHITE),
update_frame_info_scheduled_(false),
expected_content_intent_id_(0),
media_player_proxy_(NULL),
synchronous_find_active_match_ordinal_(-1),
ALLOW_THIS_IN_INITIALIZER_LIST(
load_progress_tracker_(new LoadProgressTracker(this))),
#endif
session_storage_namespace_id_(params->session_storage_namespace_id),
handling_select_range_(false),
next_snapshot_id_(0),
#if defined(OS_WIN)
focused_plugin_id_(-1),
#endif
updating_frame_tree_(false),
pending_frame_tree_update_(false),
target_process_id_(0),
target_routing_id_(0) {
#if defined(ENABLE_PLUGINS)
pepper_helper_.reset(new PepperPluginDelegateImpl(this));
#else
pepper_helper_.reset(new RenderViewPepperHelper());
#endif
set_throttle_input_events(params->renderer_prefs.throttle_input_events);
routing_id_ = params->routing_id;
surface_id_ = params->surface_id;
if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created)
opener_id_ = params->opener_id;
DCHECK_GE(next_page_id_, 0);
#if defined(ENABLE_NOTIFICATIONS)
notification_provider_ = new NotificationProvider(this);
#else
notification_provider_ = NULL;
#endif
webwidget_ = WebView::create(this);
webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_));
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
#if defined(OS_ANDROID)
content::DeviceTelephonyInfo device_info;
const std::string region_code =
command_line.HasSwitch(switches::kNetworkCountryIso)
? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso)
: device_info.GetNetworkCountryIso();
content_detectors_.push_back(linked_ptr<ContentDetector>(
new AddressDetector()));
content_detectors_.push_back(linked_ptr<ContentDetector>(
new PhoneNumberDetector(region_code)));
content_detectors_.push_back(linked_ptr<ContentDetector>(
new EmailDetector()));
#endif
if (params->counter) {
shared_popup_counter_ = params->counter;
if (!params->swapped_out)
shared_popup_counter_->data++;
decrement_shared_popup_at_destruction_ = true;
} else {
shared_popup_counter_ = new SharedRenderViewCounter(0);
decrement_shared_popup_at_destruction_ = false;
}
RenderThread::Get()->AddRoute(routing_id_, this);
AddRef();
if (opener_id_ == MSG_ROUTING_NONE) {
did_show_ = true;
CompleteInit();
}
g_view_map.Get().insert(std::make_pair(webview(), this));
g_routing_id_view_map.Get().insert(std::make_pair(routing_id_, this));
webview()->setDeviceScaleFactor(device_scale_factor_);
webkit_preferences_.Apply(webview());
webview()->initializeMainFrame(this);
if (command_line.HasSwitch(switches::kEnableTouchDragDrop))
webview()->settings()->setTouchDragDropEnabled(true);
if (!params->frame_name.empty())
webview()->mainFrame()->setName(params->frame_name);
webview()->settings()->setMinimumTimerInterval(
is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
webkit_glue::kForegroundTabTimerInterval);
OnSetRendererPrefs(params->renderer_prefs);
#if defined(ENABLE_WEBRTC)
if (!media_stream_dispatcher_)
media_stream_dispatcher_ = new MediaStreamDispatcher(this);
#endif
new MHTMLGenerator(this);
#if defined(OS_MACOSX)
new TextInputClientObserver(this);
#endif // defined(OS_MACOSX)
#if defined(OS_ANDROID)
media_player_manager_.reset(
new webkit_media::WebMediaPlayerManagerAndroid());
#endif
devtools_agent_ = new DevToolsAgent(this);
mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this);
intents_host_ = new WebIntentsHost(this);
favicon_helper_ = new FaviconHelper(this);
OnSetAccessibilityMode(params->accessibility_mode);
new IdleUserDetector(this);
if (command_line.HasSwitch(switches::kDomAutomationController))
enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION;
ProcessViewLayoutFlags(command_line);
GetContentClient()->renderer()->RenderViewCreated(this);
if (params->opener_id != MSG_ROUTING_NONE && !params->is_renderer_created) {
RenderViewImpl* opener_view = FromRoutingID(params->opener_id);
if (opener_view)
webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame());
}
if (is_swapped_out_)
NavigateToSwappedOutURL(webview()->mainFrame());
}
Commit Message: Filter more incoming URLs in the CreateWindow path.
BUG=170532
Review URL: https://chromiumcodereview.appspot.com/12036002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178728 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 6,237
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
const xmlChar *name = NULL;
xmlChar *value = NULL;
xmlChar *URI = NULL, *literal = NULL;
const xmlChar *ndata = NULL;
int isParameter = 0;
xmlChar *orig = NULL;
/* GROW; done in the caller */
if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
int inputid = ctxt->input->id;
SHRINK;
SKIP(8);
if (SKIP_BLANKS == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after '<!ENTITY'\n");
}
if (RAW == '%') {
NEXT;
if (SKIP_BLANKS == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after '%%'\n");
}
isParameter = 1;
}
name = xmlParseName(ctxt);
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
"xmlParseEntityDecl: no name\n");
return;
}
if (xmlStrchr(name, ':') != NULL) {
xmlNsErr(ctxt, XML_NS_ERR_COLON,
"colons are forbidden from entities names '%s'\n",
name, NULL, NULL);
}
if (SKIP_BLANKS == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after the entity name\n");
}
ctxt->instate = XML_PARSER_ENTITY_DECL;
/*
* handle the various case of definitions...
*/
if (isParameter) {
if ((RAW == '"') || (RAW == '\'')) {
value = xmlParseEntityValue(ctxt, &orig);
if (value) {
if ((ctxt->sax != NULL) &&
(!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
ctxt->sax->entityDecl(ctxt->userData, name,
XML_INTERNAL_PARAMETER_ENTITY,
NULL, NULL, value);
}
} else {
URI = xmlParseExternalID(ctxt, &literal, 1);
if ((URI == NULL) && (literal == NULL)) {
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
}
if (URI) {
xmlURIPtr uri;
uri = xmlParseURI((const char *) URI);
if (uri == NULL) {
xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
"Invalid URI: %s\n", URI);
/*
* This really ought to be a well formedness error
* but the XML Core WG decided otherwise c.f. issue
* E26 of the XML erratas.
*/
} else {
if (uri->fragment != NULL) {
/*
* Okay this is foolish to block those but not
* invalid URIs.
*/
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
} else {
if ((ctxt->sax != NULL) &&
(!ctxt->disableSAX) &&
(ctxt->sax->entityDecl != NULL))
ctxt->sax->entityDecl(ctxt->userData, name,
XML_EXTERNAL_PARAMETER_ENTITY,
literal, URI, NULL);
}
xmlFreeURI(uri);
}
}
}
} else {
if ((RAW == '"') || (RAW == '\'')) {
value = xmlParseEntityValue(ctxt, &orig);
if ((ctxt->sax != NULL) &&
(!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
ctxt->sax->entityDecl(ctxt->userData, name,
XML_INTERNAL_GENERAL_ENTITY,
NULL, NULL, value);
/*
* For expat compatibility in SAX mode.
*/
if ((ctxt->myDoc == NULL) ||
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
if (ctxt->myDoc == NULL) {
xmlErrMemory(ctxt, "New Doc failed");
return;
}
ctxt->myDoc->properties = XML_DOC_INTERNAL;
}
if (ctxt->myDoc->intSubset == NULL)
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
BAD_CAST "fake", NULL, NULL);
xmlSAX2EntityDecl(ctxt, name, XML_INTERNAL_GENERAL_ENTITY,
NULL, NULL, value);
}
} else {
URI = xmlParseExternalID(ctxt, &literal, 1);
if ((URI == NULL) && (literal == NULL)) {
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
}
if (URI) {
xmlURIPtr uri;
uri = xmlParseURI((const char *)URI);
if (uri == NULL) {
xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
"Invalid URI: %s\n", URI);
/*
* This really ought to be a well formedness error
* but the XML Core WG decided otherwise c.f. issue
* E26 of the XML erratas.
*/
} else {
if (uri->fragment != NULL) {
/*
* Okay this is foolish to block those but not
* invalid URIs.
*/
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
}
xmlFreeURI(uri);
}
}
if ((RAW != '>') && (SKIP_BLANKS == 0)) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required before 'NDATA'\n");
}
if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
SKIP(5);
if (SKIP_BLANKS == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after 'NDATA'\n");
}
ndata = xmlParseName(ctxt);
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->unparsedEntityDecl != NULL))
ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
literal, URI, ndata);
} else {
if ((ctxt->sax != NULL) &&
(!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
ctxt->sax->entityDecl(ctxt->userData, name,
XML_EXTERNAL_GENERAL_PARSED_ENTITY,
literal, URI, NULL);
/*
* For expat compatibility in SAX mode.
* assuming the entity repalcement was asked for
*/
if ((ctxt->replaceEntities != 0) &&
((ctxt->myDoc == NULL) ||
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
if (ctxt->myDoc == NULL) {
xmlErrMemory(ctxt, "New Doc failed");
return;
}
ctxt->myDoc->properties = XML_DOC_INTERNAL;
}
if (ctxt->myDoc->intSubset == NULL)
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
BAD_CAST "fake", NULL, NULL);
xmlSAX2EntityDecl(ctxt, name,
XML_EXTERNAL_GENERAL_PARSED_ENTITY,
literal, URI, NULL);
}
}
}
}
if (ctxt->instate == XML_PARSER_EOF)
goto done;
SKIP_BLANKS;
if (RAW != '>') {
xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
"xmlParseEntityDecl: entity %s not terminated\n", name);
xmlHaltParser(ctxt);
} else {
if (inputid != ctxt->input->id) {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Entity declaration doesn't start and stop in"
" the same entity\n");
}
NEXT;
}
if (orig != NULL) {
/*
* Ugly mechanism to save the raw entity value.
*/
xmlEntityPtr cur = NULL;
if (isParameter) {
if ((ctxt->sax != NULL) &&
(ctxt->sax->getParameterEntity != NULL))
cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
} else {
if ((ctxt->sax != NULL) &&
(ctxt->sax->getEntity != NULL))
cur = ctxt->sax->getEntity(ctxt->userData, name);
if ((cur == NULL) && (ctxt->userData==ctxt)) {
cur = xmlSAX2GetEntity(ctxt, name);
}
}
if ((cur != NULL) && (cur->orig == NULL)) {
cur->orig = orig;
orig = NULL;
}
}
done:
if (value != NULL) xmlFree(value);
if (URI != NULL) xmlFree(URI);
if (literal != NULL) xmlFree(literal);
if (orig != NULL) xmlFree(orig);
}
}
Commit Message: Detect infinite recursion in parameter entities
When expanding a parameter entity in a DTD, infinite recursion could
lead to an infinite loop or memory exhaustion.
Thanks to Wei Lei for the first of many reports.
Fixes bug 759579.
CWE ID: CWE-835
| 0
| 14,078
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderFrameHostImpl::OnRunJavaScriptDialog(
const base::string16& message,
const base::string16& default_prompt,
JavaScriptDialogType dialog_type,
IPC::Message* reply_msg) {
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT)
GetFrameResourceCoordinator()->OnAlertFired();
if (IsWaitingForUnloadACK()) {
SendJavaScriptDialogReply(reply_msg, true, base::string16());
return;
}
int32_t message_length = static_cast<int32_t>(message.length());
if (GetParent()) {
UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.Subframe", message_length);
} else {
UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.MainFrame", message_length);
}
GetProcess()->SetIgnoreInputEvents(true);
delegate_->RunJavaScriptDialog(this, message, default_prompt, dialog_type,
reply_msg);
}
Commit Message: Apply ExtensionNavigationThrottle filesystem/blob checks to all frames.
BUG=836858
Change-Id: I34333a72501129fd40b5a9aa6378c9f35f1e7fc2
Reviewed-on: https://chromium-review.googlesource.com/1028511
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Nick Carter <nick@chromium.org>
Commit-Queue: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553867}
CWE ID: CWE-20
| 0
| 4,821
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: get_random_number ()
{
int rv, pid;
/* Reset for command and process substitution. */
pid = getpid ();
if (subshell_environment && seeded_subshell != pid)
{
seedrand ();
seeded_subshell = pid;
}
do
rv = brand ();
while (rv == last_random_value);
return rv;
}
Commit Message:
CWE ID: CWE-119
| 0
| 16,225
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void gdImageHLine(gdImagePtr im, int y, int x1, int x2, int col)
{
if (im->thick > 1) {
int thickhalf = im->thick >> 1;
gdImageFilledRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col);
} else {
if (x2 < x1) {
int t = x2;
x2 = x1;
x1 = t;
}
for (; x1 <= x2; x1++) {
gdImageSetPixel(im, x1, y, col);
}
}
return;
}
Commit Message: fix #215 gdImageFillToBorder stack-overflow when invalid color is used
CWE ID: CWE-119
| 0
| 22,529
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: long TestWebKitPlatformSupport::databaseGetFileAttributes(
const WebKit::WebString& vfs_file_name) {
return SimpleDatabaseSystem::GetInstance()->GetFileAttributes(
vfs_file_name);
}
Commit Message: Use a new scheme for swapping out RenderViews.
BUG=118664
TEST=none
Review URL: http://codereview.chromium.org/9720004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127986 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 28,236
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t count)
{
int err;
unsigned long input;
struct hstate *h = kobj_to_hstate(kobj, NULL);
if (h->order >= MAX_ORDER)
return -EINVAL;
err = strict_strtoul(buf, 10, &input);
if (err)
return err;
spin_lock(&hugetlb_lock);
h->nr_overcommit_huge_pages = input;
spin_unlock(&hugetlb_lock);
return count;
}
Commit Message: hugetlb: fix resv_map leak in error path
When called for anonymous (non-shared) mappings, hugetlb_reserve_pages()
does a resv_map_alloc(). It depends on code in hugetlbfs's
vm_ops->close() to release that allocation.
However, in the mmap() failure path, we do a plain unmap_region() without
the remove_vma() which actually calls vm_ops->close().
This is a decent fix. This leak could get reintroduced if new code (say,
after hugetlb_reserve_pages() in hugetlbfs_file_mmap()) decides to return
an error. But, I think it would have to unroll the reservation anyway.
Christoph's test case:
http://marc.info/?l=linux-mm&m=133728900729735
This patch applies to 3.4 and later. A version for earlier kernels is at
https://lkml.org/lkml/2012/5/22/418.
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reported-by: Christoph Lameter <cl@linux.com>
Tested-by: Christoph Lameter <cl@linux.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: <stable@vger.kernel.org> [2.6.32+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-399
| 0
| 14,115
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void GetDownloads(Browser* browser,
std::vector<DownloadItem*>* downloads) const {
DCHECK(downloads);
DownloadManager* manager = DownloadManagerForBrowser(browser);
manager->GetAllDownloads(downloads);
}
Commit Message: When turning a download into a navigation, navigate the right frame
Code changes from Nate Chapin <japhet@chromium.org>
Bug: 926105
Change-Id: I098599394e6ebe7d2fce5af838014297a337d294
Reviewed-on: https://chromium-review.googlesource.com/c/1454962
Reviewed-by: Camille Lamy <clamy@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629547}
CWE ID: CWE-284
| 0
| 20,269
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,
loff_t *f_pos)
{
struct bcm_tarang_data *pTarang = filp->private_data;
struct bcm_mini_adapter *Adapter = pTarang->Adapter;
struct sk_buff *Packet = NULL;
ssize_t PktLen = 0;
int wait_ret_val = 0;
unsigned long ret = 0;
wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue,
(pTarang->RxAppControlHead ||
Adapter->device_removed));
if ((wait_ret_val == -ERESTARTSYS)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"Exiting as i've been asked to exit!!!\n");
return wait_ret_val;
}
if (Adapter->device_removed) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"Device Removed... Killing the Apps...\n");
return -ENODEV;
}
if (FALSE == Adapter->fw_download_done)
return -EACCES;
down(&Adapter->RxAppControlQueuelock);
if (pTarang->RxAppControlHead) {
Packet = pTarang->RxAppControlHead;
DEQUEUEPACKET(pTarang->RxAppControlHead,
pTarang->RxAppControlTail);
pTarang->AppCtrlQueueLen--;
}
up(&Adapter->RxAppControlQueuelock);
if (Packet) {
PktLen = Packet->len;
ret = copy_to_user(buf, Packet->data,
min_t(size_t, PktLen, size));
if (ret) {
dev_kfree_skb(Packet);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
"Returning from copy to user failure\n");
return -EFAULT;
}
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,
"Read %zd Bytes From Adapter packet = %p by process %d!\n",
PktLen, Packet, current->pid);
dev_kfree_skb(Packet);
}
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<\n");
return PktLen;
}
Commit Message: Staging: bcm: info leak in ioctl
The DevInfo.u32Reserved[] array isn't initialized so it leaks kernel
information to user space.
Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-200
| 0
| 29,128
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: CStarter::Config()
{
if( Execute ) {
free( Execute );
}
if( (Execute = param("EXECUTE")) == NULL ) {
if( is_gridshell ) {
Execute = strdup( orig_cwd );
} else {
EXCEPT("Execute directory not specified in config file.");
}
}
if (!m_configured) {
bool ps = privsep_enabled();
bool gl = param_boolean("GLEXEC_JOB", false);
#if !defined(LINUX)
dprintf(D_ALWAYS,
"GLEXEC_JOB not supported on this platform; "
"ignoring\n");
gl = false;
#endif
if (ps && gl) {
EXCEPT("can't support both "
"PRIVSEP_ENABLED and GLEXEC_JOB");
}
if (ps) {
m_privsep_helper = new CondorPrivSepHelper;
ASSERT(m_privsep_helper != NULL);
}
else if (gl) {
#if defined(LINUX)
m_privsep_helper = new GLExecPrivSepHelper;
ASSERT(m_privsep_helper != NULL);
#endif
}
}
jic->config();
m_configured = true;
}
Commit Message:
CWE ID: CWE-134
| 0
| 14,504
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool ASF_Support::ReadHeaderExtensionObject ( XMP_IO* fileRef, ObjectState& inOutObjectState, const XMP_Uns64& _pos, const ASF_ObjectBase& _objectBase )
{
if ( ! IsEqualGUID ( ASF_Header_Extension_Object, _objectBase.guid) || (! legacyManager ) ) return false;
try {
const XMP_Uns64 offset = 46;
XMP_Uns64 read = 0;
XMP_Uns64 data = (_objectBase.size - offset);
XMP_Uns64 pos = (_pos + offset);
ASF_ObjectBase objectBase;
while ( read < data ) {
fileRef->Seek ( pos, kXMP_SeekFromStart );
if ( kASF_ObjectBaseLen != fileRef->Read ( &objectBase, kASF_ObjectBaseLen, true ) ) break;
objectBase.size = GetUns64LE ( &objectBase.size );
if ( IsEqualGUID ( ASF_Padding_Object, objectBase.guid ) ) {
legacyManager->SetPadding ( legacyManager->GetPadding() + (objectBase.size - 24) );
}
pos += objectBase.size;
read += objectBase.size;
}
} catch ( ... ) {
return false;
}
return true;
}
Commit Message:
CWE ID: CWE-835
| 0
| 10,387
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: struct tty_driver *alloc_tty_driver(int lines)
{
struct tty_driver *driver;
driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL);
if (driver) {
kref_init(&driver->kref);
driver->magic = TTY_DRIVER_MAGIC;
driver->num = lines;
/* later we'll move allocation of tables here */
}
return driver;
}
Commit Message: TTY: drop driver reference in tty_open fail path
When tty_driver_lookup_tty fails in tty_open, we forget to drop a
reference to the tty driver. This was added by commit 4a2b5fddd5 (Move
tty lookup/reopen to caller).
Fix that by adding tty_driver_kref_put to the fail path.
I will refactor the code later. This is for the ease of backporting to
stable.
Introduced-in: v2.6.28-rc2
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: stable <stable@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Acked-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
CWE ID:
| 0
| 3,019
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: proc_do_sync_threshold(ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int *valp = table->data;
int val[2];
int rc;
/* backup the value first */
memcpy(val, valp, sizeof(val));
rc = proc_dointvec(table, write, buffer, lenp, ppos);
if (write && (valp[0] < 0 || valp[1] < 0 ||
(valp[0] >= valp[1] && valp[1]))) {
/* Restore the correct value */
memcpy(valp, val, sizeof(val));
}
return rc;
}
Commit Message: ipvs: fix info leak in getsockopt(IP_VS_SO_GET_TIMEOUT)
If at least one of CONFIG_IP_VS_PROTO_TCP or CONFIG_IP_VS_PROTO_UDP is
not set, __ip_vs_get_timeouts() does not fully initialize the structure
that gets copied to userland and that for leaks up to 12 bytes of kernel
stack. Add an explicit memset(0) before passing the structure to
__ip_vs_get_timeouts() to avoid the info leak.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Wensong Zhang <wensong@linux-vs.org>
Cc: Simon Horman <horms@verge.net.au>
Cc: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-200
| 0
| 21,693
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int shmem_unuse(swp_entry_t swap, struct page *page)
{
return 0;
}
Commit Message: tmpfs: fix use-after-free of mempolicy object
The tmpfs remount logic preserves filesystem mempolicy if the mpol=M
option is not specified in the remount request. A new policy can be
specified if mpol=M is given.
Before this patch remounting an mpol bound tmpfs without specifying
mpol= mount option in the remount request would set the filesystem's
mempolicy object to a freed mempolicy object.
To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run:
# mkdir /tmp/x
# mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0
# mount -o remount,size=200M nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0
# note ? garbage in mpol=... output above
# dd if=/dev/zero of=/tmp/x/f count=1
# panic here
Panic:
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [< (null)>] (null)
[...]
Oops: 0010 [#1] SMP DEBUG_PAGEALLOC
Call Trace:
mpol_shared_policy_init+0xa5/0x160
shmem_get_inode+0x209/0x270
shmem_mknod+0x3e/0xf0
shmem_create+0x18/0x20
vfs_create+0xb5/0x130
do_last+0x9a1/0xea0
path_openat+0xb3/0x4d0
do_filp_open+0x42/0xa0
do_sys_open+0xfe/0x1e0
compat_sys_open+0x1b/0x20
cstar_dispatch+0x7/0x1f
Non-debug kernels will not crash immediately because referencing the
dangling mpol will not cause a fault. Instead the filesystem will
reference a freed mempolicy object, which will cause unpredictable
behavior.
The problem boils down to a dropped mpol reference below if
shmem_parse_options() does not allocate a new mpol:
config = *sbinfo
shmem_parse_options(data, &config, true)
mpol_put(sbinfo->mpol)
sbinfo->mpol = config.mpol /* BUG: saves unreferenced mpol */
This patch avoids the crash by not releasing the mempolicy if
shmem_parse_options() doesn't create a new mpol.
How far back does this issue go? I see it in both 2.6.36 and 3.3. I did
not look back further.
Signed-off-by: Greg Thelen <gthelen@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-399
| 0
| 14,941
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.