func
stringlengths 0
484k
| target
int64 0
1
| cwe
listlengths 0
4
| project
stringclasses 799
values | commit_id
stringlengths 40
40
| hash
float64 1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
| size
int64 1
24k
| message
stringlengths 0
13.3k
|
---|---|---|---|---|---|---|---|
OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{
static const char module[]="OJPEGEncode";
(void)buf;
(void)cc;
(void)s;
TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead");
return(0);
} | 0 | [
"CWE-369"
]
| libtiff | 43bc256d8ae44b92d2734a3c5bc73957a4d7c1ec | 172,094,837,166,852,400,000,000,000,000,000,000,000 | 9 | * libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of failure in
OJPEGPreDecode(). This will avoid a divide by zero, and potential other issues.
Reported by Agostino Sarubbo.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611 |
static avifBool avifParseFileTypeBox(avifFileType * ftyp, const uint8_t * raw, size_t rawLen)
{
BEGIN_STREAM(s, raw, rawLen);
CHECK(avifROStreamRead(&s, ftyp->majorBrand, 4));
CHECK(avifROStreamReadU32(&s, &ftyp->minorVersion));
size_t compatibleBrandsBytes = avifROStreamRemainingBytes(&s);
if ((compatibleBrandsBytes % 4) != 0) {
return AVIF_FALSE;
}
ftyp->compatibleBrands = avifROStreamCurrent(&s);
CHECK(avifROStreamSkip(&s, compatibleBrandsBytes));
ftyp->compatibleBrandsCount = (int)compatibleBrandsBytes / 4;
return AVIF_TRUE;
} | 0 | [
"CWE-703",
"CWE-787"
]
| libavif | 0a8e7244d494ae98e9756355dfbfb6697ded2ff9 | 270,194,956,058,068,900,000,000,000,000,000,000,000 | 17 | Set max image size to 16384 * 16384
Fix https://crbug.com/oss-fuzz/24728 and
https://crbug.com/oss-fuzz/24734. |
xfs_attr_shortform_verify(
struct xfs_inode *ip)
{
struct xfs_attr_shortform *sfp;
struct xfs_attr_sf_entry *sfep;
struct xfs_attr_sf_entry *next_sfep;
char *endp;
struct xfs_ifork *ifp;
int i;
int64_t size;
ASSERT(ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL);
ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
sfp = (struct xfs_attr_shortform *)ifp->if_u1.if_data;
size = ifp->if_bytes;
/*
* Give up if the attribute is way too short.
*/
if (size < sizeof(struct xfs_attr_sf_hdr))
return __this_address;
endp = (char *)sfp + size;
/* Check all reported entries */
sfep = &sfp->list[0];
for (i = 0; i < sfp->hdr.count; i++) {
/*
* struct xfs_attr_sf_entry has a variable length.
* Check the fixed-offset parts of the structure are
* within the data buffer.
*/
if (((char *)sfep + sizeof(*sfep)) >= endp)
return __this_address;
/* Don't allow names with known bad length. */
if (sfep->namelen == 0)
return __this_address;
/*
* Check that the variable-length part of the structure is
* within the data buffer. The next entry starts after the
* name component, so nextentry is an acceptable test.
*/
next_sfep = XFS_ATTR_SF_NEXTENTRY(sfep);
if ((char *)next_sfep > endp)
return __this_address;
/*
* Check for unknown flags. Short form doesn't support
* the incomplete or local bits, so we can use the namespace
* mask here.
*/
if (sfep->flags & ~XFS_ATTR_NSP_ONDISK_MASK)
return __this_address;
/*
* Check for invalid namespace combinations. We only allow
* one namespace flag per xattr, so we can just count the
* bits (i.e. hweight) here.
*/
if (hweight8(sfep->flags & XFS_ATTR_NSP_ONDISK_MASK) > 1)
return __this_address;
sfep = next_sfep;
}
if ((void *)sfep != (void *)endp)
return __this_address;
return NULL;
} | 1 | [
"CWE-131"
]
| linux | f4020438fab05364018c91f7e02ebdd192085933 | 126,444,536,306,646,410,000,000,000,000,000,000,000 | 71 | xfs: fix boundary test in xfs_attr_shortform_verify
The boundary test for the fixed-offset parts of xfs_attr_sf_entry in
xfs_attr_shortform_verify is off by one, because the variable array
at the end is defined as nameval[1] not nameval[].
Hence we need to subtract 1 from the calculation.
This can be shown by:
# touch file
# setfattr -n root.a file
and verifications will fail when it's written to disk.
This only matters for a last attribute which has a single-byte name
and no value, otherwise the combination of namelen & valuelen will
push endp further out and this test won't fail.
Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs")
Signed-off-by: Eric Sandeen <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]> |
sds sdstrim(sds s, const char *cset) {
char *end, *sp, *ep;
size_t len;
sp = s;
ep = end = s+sdslen(s)-1;
while(sp <= end && strchr(cset, *sp)) sp++;
while(ep > sp && strchr(cset, *ep)) ep--;
len = (sp > ep) ? 0 : ((ep-sp)+1);
if (s != sp) memmove(s, sp, len);
s[len] = '\0';
sdssetlen(s,len);
return s;
} | 0 | [
"CWE-190"
]
| redis | 24cc0b984d4ed5045c6ff125b0e619b6ce5ea9c6 | 276,618,140,715,334,920,000,000,000,000,000,000,000 | 14 | Fix integer overflow in _sdsMakeRoomFor (CVE-2021-41099) (#9558)
The existing overflow checks handled the greedy growing, but didn't handle
a case where the addition of the header size is what causes the overflow. |
fmtfloat(double value, char type, int forcesign, int leftjust,
int minlen, int zpad, int precision, int pointflag,
PrintfTarget *target)
{
int signvalue = 0;
int vallen;
char fmt[32];
char convert[512];
int padlen = 0; /* amount to pad */
/* we rely on regular C library's sprintf to do the basic conversion */
if (pointflag)
sprintf(fmt, "%%.%d%c", precision, type);
else
sprintf(fmt, "%%%c", type);
if (adjust_sign((value < 0), forcesign, &signvalue))
value = -value;
vallen = sprintf(convert, fmt, value);
adjust_padlen(minlen, vallen, leftjust, &padlen);
leading_pad(zpad, &signvalue, &padlen, target);
dostr(convert, vallen, target);
trailing_pad(&padlen, target);
} | 1 | [
"CWE-787"
]
| postgres | 29725b3db67ad3f09da1a7fb6690737d2f8d6c0a | 212,199,891,126,731,070,000,000,000,000,000,000,000 | 29 | port/snprintf(): fix overflow and do padding
Prevent port/snprintf() from overflowing its local fixed-size
buffer and pad to the desired number of digits with zeros, even
if the precision is beyond the ability of the native sprintf().
port/snprintf() is only used on systems that lack a native
snprintf().
Reported by Bruce Momjian. Patch by Tom Lane. Backpatch to all
supported versions.
Security: CVE-2015-0242 |
GF_EXPORT
GF_Box *gf_isom_box_new(u32 boxType)
{
return gf_isom_box_new_ex(boxType, 0, 0, GF_FALSE); | 0 | [
"CWE-476"
]
| gpac | d527325a9b72218612455a534a508f9e1753f76e | 86,705,781,898,527,320,000,000,000,000,000,000,000 | 4 | fixed #1768 |
nautilus_file_operations_new_file (GtkWidget *parent_view,
GdkPoint *target_point,
const char *parent_dir,
const char *target_filename,
const char *initial_contents,
NautilusCreateCallback done_callback,
gpointer done_callback_data)
{
CreateJob *job;
GtkWindow *parent_window;
parent_window = NULL;
if (parent_view) {
parent_window = (GtkWindow *)gtk_widget_get_ancestor (parent_view, GTK_TYPE_WINDOW);
}
job = op_job_new (CreateJob, parent_window);
job->done_callback = done_callback;
job->done_callback_data = done_callback_data;
job->dest_dir = g_file_new_for_uri (parent_dir);
if (target_point != NULL) {
job->position = *target_point;
job->has_position = TRUE;
}
job->src_data = g_strdup (initial_contents);
job->filename = g_strdup (target_filename);
g_io_scheduler_push_job (create_job,
job,
NULL, /* destroy notify */
0,
job->common.cancellable);
} | 0 | []
| nautilus | ca2fd475297946f163c32dcea897f25da892b89d | 76,143,151,799,708,400,000,000,000,000,000,000,000 | 33 | Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if
2009-02-24 Alexander Larsson <[email protected]>
* libnautilus-private/nautilus-file-operations.c:
* libnautilus-private/nautilus-file-operations.h:
Add nautilus_file_mark_desktop_file_trusted(), this now
adds a #! line if there is none as well as makes the file
executable.
* libnautilus-private/nautilus-mime-actions.c:
Use nautilus_file_mark_desktop_file_trusted() instead of
just setting the permissions.
svn path=/trunk/; revision=15006 |
authority_type_to_string(authority_type_t auth)
{
char *result;
smartlist_t *lst = smartlist_create();
if (auth & V1_AUTHORITY)
smartlist_add(lst, (void*)"V1");
if (auth & V2_AUTHORITY)
smartlist_add(lst, (void*)"V2");
if (auth & V3_AUTHORITY)
smartlist_add(lst, (void*)"V3");
if (auth & BRIDGE_AUTHORITY)
smartlist_add(lst, (void*)"Bridge");
if (auth & HIDSERV_AUTHORITY)
smartlist_add(lst, (void*)"Hidden service");
if (smartlist_len(lst)) {
result = smartlist_join_strings(lst, ", ", 0, NULL);
} else {
result = tor_strdup("[Not an authority]");
}
smartlist_free(lst);
return result;
} | 0 | []
| tor | 973c18bf0e84d14d8006a9ae97fde7f7fb97e404 | 85,140,092,310,883,920,000,000,000,000,000,000,000 | 22 | Fix assertion failure in tor_timegm.
Fixes bug 6811. |
GF_Err dac3_box_size(GF_Box *s)
{
GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;
if (ptr->cfg.is_ec3) {
u32 i;
s->size += 2;
for (i=0; i<ptr->cfg.nb_streams; i++) {
s->size += 3;
if (ptr->cfg.streams[i].nb_dep_sub)
s->size += 1;
}
} else {
s->size += 3;
}
return GF_OK; | 0 | [
"CWE-787"
]
| gpac | 388ecce75d05e11fc8496aa4857b91245007d26e | 274,779,853,187,633,720,000,000,000,000,000,000,000 | 17 | fixed #1587 |
static int selinux_ismaclabel(const char *name)
{
return (strcmp(name, XATTR_SELINUX_SUFFIX) == 0);
} | 0 | [
"CWE-264"
]
| linux | 7b0d0b40cd78cadb525df760ee4cac151533c2b5 | 198,387,163,828,065,300,000,000,000,000,000,000,000 | 4 | selinux: Permit bounded transitions under NO_NEW_PRIVS or NOSUID.
If the callee SID is bounded by the caller SID, then allowing
the transition to occur poses no risk of privilege escalation and we can
therefore safely allow the transition to occur. Add this exemption
for both the case where a transition was explicitly requested by the
application and the case where an automatic transition is defined in
policy.
Signed-off-by: Stephen Smalley <[email protected]>
Reviewed-by: Andy Lutomirski <[email protected]>
Signed-off-by: Paul Moore <[email protected]> |
smb2_hdr_assemble(struct smb2_sync_hdr *shdr, __le16 smb2_cmd,
const struct cifs_tcon *tcon)
{
shdr->ProtocolId = SMB2_PROTO_NUMBER;
shdr->StructureSize = cpu_to_le16(64);
shdr->Command = smb2_cmd;
if (tcon && tcon->ses && tcon->ses->server) {
struct TCP_Server_Info *server = tcon->ses->server;
spin_lock(&server->req_lock);
/* Request up to 10 credits but don't go over the limit. */
if (server->credits >= server->max_credits)
shdr->CreditRequest = cpu_to_le16(0);
else
shdr->CreditRequest = cpu_to_le16(
min_t(int, server->max_credits -
server->credits, 10));
spin_unlock(&server->req_lock);
} else {
shdr->CreditRequest = cpu_to_le16(2);
}
shdr->ProcessId = cpu_to_le32((__u16)current->tgid);
if (!tcon)
goto out;
/* GLOBAL_CAP_LARGE_MTU will only be set if dialect > SMB2.02 */
/* See sections 2.2.4 and 3.2.4.1.5 of MS-SMB2 */
if ((tcon->ses) && (tcon->ses->server) &&
(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
shdr->CreditCharge = cpu_to_le16(1);
/* else CreditCharge MBZ */
shdr->TreeId = tcon->tid;
/* Uid is not converted */
if (tcon->ses)
shdr->SessionId = tcon->ses->Suid;
/*
* If we would set SMB2_FLAGS_DFS_OPERATIONS on open we also would have
* to pass the path on the Open SMB prefixed by \\server\share.
* Not sure when we would need to do the augmented path (if ever) and
* setting this flag breaks the SMB2 open operation since it is
* illegal to send an empty path name (without \\server\share prefix)
* when the DFS flag is set in the SMB open header. We could
* consider setting the flag on all operations other than open
* but it is safer to net set it for now.
*/
/* if (tcon->share_flags & SHI1005_FLAGS_DFS)
shdr->Flags |= SMB2_FLAGS_DFS_OPERATIONS; */
if (tcon->ses && tcon->ses->server && tcon->ses->server->sign &&
!smb3_encryption_required(tcon))
shdr->Flags |= SMB2_FLAGS_SIGNED;
out:
return;
} | 0 | [
"CWE-416",
"CWE-200"
]
| linux | 6a3eb3360667170988f8a6477f6686242061488a | 111,193,882,058,013,520,000,000,000,000,000,000,000 | 57 | cifs: Fix use-after-free in SMB2_write
There is a KASAN use-after-free:
BUG: KASAN: use-after-free in SMB2_write+0x1342/0x1580
Read of size 8 at addr ffff8880b6a8e450 by task ln/4196
Should not release the 'req' because it will use in the trace.
Fixes: eccb4422cf97 ("smb3: Add ftrace tracepoints for improved SMB3 debugging")
Signed-off-by: ZhangXiaoxu <[email protected]>
Signed-off-by: Steve French <[email protected]>
CC: Stable <[email protected]> 4.18+
Reviewed-by: Pavel Shilovsky <[email protected]> |
static uint32_t clear_linked(volatile event_word_t *word)
{
event_word_t new, old, w;
w = *word;
do {
old = w;
new = (w & ~((1 << EVTCHN_FIFO_LINKED)
| EVTCHN_FIFO_LINK_MASK));
} while ((w = sync_cmpxchg(word, old, new)) != old);
return w & EVTCHN_FIFO_LINK_MASK;
} | 0 | [
"CWE-400",
"CWE-703"
]
| linux | e99502f76271d6bc4e374fe368c50c67a1fd3070 | 92,309,245,514,856,580,000,000,000,000,000,000,000 | 14 | xen/events: defer eoi in case of excessive number of events
In case rogue guests are sending events at high frequency it might
happen that xen_evtchn_do_upcall() won't stop processing events in
dom0. As this is done in irq handling a crash might be the result.
In order to avoid that, delay further inter-domain events after some
time in xen_evtchn_do_upcall() by forcing eoi processing into a
worker on the same cpu, thus inhibiting new events coming in.
The time after which eoi processing is to be delayed is configurable
via a new module parameter "event_loop_timeout" which specifies the
maximum event loop time in jiffies (default: 2, the value was chosen
after some tests showing that a value of 2 was the lowest with an
only slight drop of dom0 network throughput while multiple guests
performed an event storm).
How long eoi processing will be delayed can be specified via another
parameter "event_eoi_delay" (again in jiffies, default 10, again the
value was chosen after testing with different delay values).
This is part of XSA-332.
Cc: [email protected]
Reported-by: Julien Grall <[email protected]>
Signed-off-by: Juergen Gross <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]>
Reviewed-by: Wei Liu <[email protected]> |
evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints)
{
if (!(hints->ai_flags & EVUTIL_AI_ADDRCONFIG))
return;
if (hints->ai_family != PF_UNSPEC)
return;
if (!have_checked_interfaces)
evutil_check_interfaces(0);
if (had_ipv4_address && !had_ipv6_address) {
hints->ai_family = PF_INET;
} else if (!had_ipv4_address && had_ipv6_address) {
hints->ai_family = PF_INET6;
}
} | 0 | [
"CWE-119",
"CWE-787"
]
| libevent | 329acc18a0768c21ba22522f01a5c7f46cacc4d5 | 106,417,788,567,233,150,000,000,000,000,000,000,000 | 14 | evutil_parse_sockaddr_port(): fix buffer overflow
@asn-the-goblin-slayer:
"Length between '[' and ']' is cast to signed 32 bit integer on line 1815. Is
the length is more than 2<<31 (INT_MAX), len will hold a negative value.
Consequently, it will pass the check at line 1816. Segfault happens at line
1819.
Generate a resolv.conf with generate-resolv.conf, then compile and run
poc.c. See entry-functions.txt for functions in tor that might be
vulnerable.
Please credit 'Guido Vranken' for this discovery through the Tor bug bounty
program."
Reproducer for gdb (https://gist.github.com/azat/be2b0d5e9417ba0dfe2c):
start
p (1ULL<<31)+1ULL
# $1 = 2147483649
p malloc(sizeof(struct sockaddr))
# $2 = (void *) 0x646010
p malloc(sizeof(int))
# $3 = (void *) 0x646030
p malloc($1)
# $4 = (void *) 0x7fff76a2a010
p memset($4, 1, $1)
# $5 = 1990369296
p (char *)$4
# $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
set $6[0]='['
set $6[$1]=']'
p evutil_parse_sockaddr_port($4, $2, $3)
# $7 = -1
Before:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb)
Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at memcpy-sse2-unaligned.S:36
After:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb) $7 = -1
(gdb) (gdb) quit
Fixes: #318 |
static void ipc_xrun(struct snd_sof_dev *sdev, u32 msg_id)
{
struct snd_sof_pcm_stream *stream;
struct sof_ipc_stream_posn posn;
struct snd_sof_pcm *spcm;
int direction;
spcm = snd_sof_find_spcm_comp(sdev, msg_id, &direction);
if (!spcm) {
dev_err(sdev->dev, "error: XRUN for unknown stream, msg_id %d\n",
msg_id);
return;
}
stream = &spcm->stream[direction];
snd_sof_ipc_msg_data(sdev, stream->substream, &posn, sizeof(posn));
dev_dbg(sdev->dev, "posn XRUN: host %llx comp %d size %d\n",
posn.host_posn, posn.xrun_comp_id, posn.xrun_size);
#if defined(CONFIG_SND_SOC_SOF_DEBUG_XRUN_STOP)
/* stop PCM on XRUN - used for pipeline debug */
memcpy(&stream->posn, &posn, sizeof(posn));
snd_pcm_stop_xrun(stream->substream);
#endif
} | 0 | [
"CWE-400",
"CWE-401"
]
| linux | 45c1380358b12bf2d1db20a5874e9544f56b34ab | 63,611,449,458,786,730,000,000,000,000,000,000,000 | 26 | ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data
In the implementation of sof_set_get_large_ctrl_data() there is a memory
leak in case an error. Release partdata if sof_get_ctrl_copy_params()
fails.
Fixes: 54d198d5019d ("ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly")
Signed-off-by: Navid Emamdoost <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]> |
e_get_user_cache_dir (void)
{
static gchar *dirname = NULL;
if (G_UNLIKELY (dirname == NULL)) {
const gchar *cache_dir = g_get_user_cache_dir ();
dirname = g_build_filename (cache_dir, "evolution", NULL);
g_mkdir_with_parents (dirname, 0700);
}
return dirname;
} | 0 | [
"CWE-295"
]
| evolution-data-server | 6672b8236139bd6ef41ecb915f4c72e2a052dba5 | 289,149,776,938,312,770,000,000,000,000,000,000,000 | 12 | Let child source with 'none' authentication method use collection source authentication
That might be the same as having set NULL authentication method.
Related to https://gitlab.gnome.org/GNOME/evolution-ews/issues/27 |
static void mptsas_free_request(MPTSASRequest *req)
{
MPTSASState *s = req->dev;
if (req->sreq != NULL) {
req->sreq->hba_private = NULL;
scsi_req_unref(req->sreq);
req->sreq = NULL;
QTAILQ_REMOVE(&s->pending, req, next);
}
qemu_sglist_destroy(&req->qsg);
g_free(req);
} | 1 | [
"CWE-416"
]
| qemu | 3791642c8d60029adf9b00bcb4e34d7d8a1aea4d | 314,461,033,473,736,800,000,000,000,000,000,000,000 | 13 | mptsas: Remove unused MPTSASState 'pending' field (CVE-2021-3392)
While processing SCSI i/o requests in mptsas_process_scsi_io_request(),
the Megaraid emulator appends new MPTSASRequest object 'req' to
the 's->pending' queue. In case of an error, this same object gets
dequeued in mptsas_free_request() only if SCSIRequest object
'req->sreq' is initialised. This may lead to a use-after-free issue.
Since s->pending is actually not used, simply remove it from
MPTSASState.
Cc: [email protected]
Signed-off-by: Michael Tokarev <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reported-by: Cheolwoo Myung <[email protected]>
Message-id: [email protected]
Message-Id: <[email protected]>
Suggested-by: Paolo Bonzini <[email protected]>
Reported-by: Cheolwoo Myung <[email protected]>
BugLink: https://bugs.launchpad.net/qemu/+bug/1914236 (CVE-2021-3392)
Fixes: e351b826112 ("hw: Add support for LSI SAS1068 (mptsas) device")
[PMD: Reworded description, added more tags]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]> |
gs_pdf14_device_push(gs_memory_t *mem, gs_gstate * pgs,
gx_device ** pdev, gx_device * target, const gs_pdf14trans_t * pdf14pct)
{
pdf14_device * dev_proto;
pdf14_device * p14dev, temp_dev_proto;
int code;
bool has_tags;
cmm_profile_t *icc_profile;
gsicc_rendering_param_t render_cond;
cmm_dev_profile_t *dev_profile;
uchar k;
int max_bitmap;
bool use_pdf14_accum = false;
/* Guard against later seg faults, this should not be possible */
if (target == NULL)
return gs_throw_code(gs_error_Fatal);
has_tags = device_encodes_tags(target);
max_bitmap = target->space_params.MaxBitmap == 0 ? MAX_BITMAP :
target->space_params.MaxBitmap;
/* If the device is not a printer class device, it won't support saved-pages */
/* and so we may need to make a clist device in order to prevent very large */
/* or high resolution pages from having allocation problems. */
/* We use MaxBitmap to decide when a clist is needed.*/
if (dev_proc(target, dev_spec_op)(target, gxdso_supports_saved_pages, NULL, 0) <= 0 &&
gx_device_is_pattern_clist(target) == 0 &&
gx_device_is_pattern_accum(target) == 0 &&
gs_device_is_memory(target) == 0) {
uint32_t pdf14_trans_buffer_size = (ESTIMATED_PDF14_ROW_SPACE(max(1, target->width),
target->color_info.num_components) >> 3);
if (target->height < max_ulong / pdf14_trans_buffer_size)
pdf14_trans_buffer_size *= target->height;
else
max_bitmap = 0; /* Force decision to clist */
if (pdf14_trans_buffer_size > max_bitmap)
use_pdf14_accum = true;
}
code = dev_proc(target, get_profile)(target, &dev_profile);
if (code < 0)
return code;
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &icc_profile,
&render_cond);
if_debug0m('v', mem, "[v]gs_pdf14_device_push\n");
code = get_pdf14_device_proto(target, &dev_proto, &temp_dev_proto, pgs,
pdf14pct, use_pdf14_accum);
if (code < 0)
return code;
code = gs_copydevice((gx_device **) &p14dev,
(const gx_device *) dev_proto, mem);
if (code < 0)
return code;
gs_pdf14_device_copy_params((gx_device *)p14dev, target);
gx_device_set_target((gx_device_forward *)p14dev, target);
p14dev->pad = target->pad;
p14dev->log2_align_mod = target->log2_align_mod;
p14dev->is_planar = target->is_planar;
/* If the target profile was CIELAB (and we are not using a blend CS),
then overide with default RGB for
proper blending. During put_image we will convert from RGB to
CIELAB. Need to check that we have a default profile, which
will not be the case if we are coming from the clist reader */
if ((icc_profile->data_cs == gsCIELAB || icc_profile->islab)
&& pgs->icc_manager->default_rgb != NULL && !p14dev->using_blend_cs) {
gsicc_adjust_profile_rc(pgs->icc_manager->default_rgb, 1, "gs_pdf14_device_push");
gsicc_adjust_profile_rc(p14dev->icc_struct->device_profile[0], -1, "gs_pdf14_device_push");
p14dev->icc_struct->device_profile[0] = pgs->icc_manager->default_rgb;
}
/* The number of color planes should not exceed that of the target.
Unless we are using a blend CS */
if (!p14dev->using_blend_cs) {
if (p14dev->color_info.num_components > target->color_info.num_components)
p14dev->color_info.num_components = target->color_info.num_components;
if (p14dev->color_info.max_components > target->color_info.max_components)
p14dev->color_info.max_components = target->color_info.max_components;
}
p14dev->color_info.depth = p14dev->color_info.num_components * 8;
/* If we have a tag device then go ahead and do a special encoder
decoder for the pdf14 device to make sure we maintain this
information in the encoded color information. We could use
the target device's methods but the PDF14 device has to maintain
8 bit color always and we could run into other issues if the number
of colorants became large. If we need to do compressed color with
tags that will be a special project at that time */
if (has_tags) {
set_dev_proc(p14dev, encode_color, pdf14_encode_color_tag);
p14dev->color_info.comp_shift[p14dev->color_info.num_components] = p14dev->color_info.depth;
p14dev->color_info.depth += 8;
}
/* by definition pdf14_encode _is_ standard */
p14dev->color_info.separable_and_linear = GX_CINFO_SEP_LIN_STANDARD;
gx_device_fill_in_procs((gx_device *)p14dev);
p14dev->save_get_cmap_procs = pgs->get_cmap_procs;
pgs->get_cmap_procs = pdf14_get_cmap_procs;
gx_set_cmap_procs(pgs, (gx_device *)p14dev);
/* Components shift, etc have to be based upon 8 bit */
for (k = 0; k < p14dev->color_info.num_components; k++) {
p14dev->color_info.comp_bits[k] = 8;
p14dev->color_info.comp_shift[k] =
(p14dev->color_info.num_components - 1 - k) * 8;
}
if (use_pdf14_accum) {
/* we will disable this device later, but we don't want to allocate large buffers */
p14dev->width = 1;
p14dev->height = 1;
}
code = dev_proc((gx_device *) p14dev, open_device) ((gx_device *) p14dev);
*pdev = (gx_device *) p14dev;
pdf14_set_marking_params((gx_device *)p14dev, pgs);
p14dev->trans_group_parent_cmap_procs = NULL;
/* In case we have alphabits set */
p14dev->color_info.anti_alias = target->color_info.anti_alias;
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(p14dev->ctx->stack->rect.q.y-p14dev->ctx->stack->rect.p.y,
p14dev->ctx->stack->rect.q.x-p14dev->ctx->stack->rect.p.x,
p14dev->ctx->stack->n_planes,
p14dev->ctx->stack->planestride, p14dev->ctx->stack->rowstride,
"Device_Push",p14dev->ctx->stack->data);
global_index++;
#endif
/* We should never go into this when using a blend color space */
if (use_pdf14_accum) {
const gx_device_pdf14_accum *accum_proto = NULL;
gx_device *new_target = NULL;
gx_device_color pdcolor;
frac pconc_white = frac_1;
if_debug0m('v', mem, "[v]gs_pdf14_device_push: Inserting clist device.\n");
/* get the prototype for the accumulator device based on colorspace */
switch (target->color_info.num_components) {
case 1:
accum_proto = &pdf14_accum_Gray;
break;
case 3:
accum_proto = &pdf14_accum_RGB;
break;
case 4:
accum_proto = &pdf14_accum_CMYK;
break;
default:
/* FIXME: DeviceN ?? */
break; /* accum_proto will be NULL, so no accum device */
}
if (accum_proto == NULL ||
(code = gs_copydevice(&new_target, (gx_device *)accum_proto, mem->stable_memory)) < 0)
goto no_clist_accum;
((gx_device_pdf14_accum *)new_target)->save_p14dev = (gx_device *)p14dev; /* non-clist p14dev */
/* Fill in values from the target device before opening */
new_target->color_info.separable_and_linear = GX_CINFO_SEP_LIN;
new_target->color_info.anti_alias = p14dev->color_info.anti_alias;
set_linear_color_bits_mask_shift(new_target);
gs_pdf14_device_copy_params(new_target, target);
((gx_device_pdf14_accum *)new_target)->page_uses_transparency = true;
gx_device_fill_in_procs(new_target);
memcpy(&(new_target->space_params), &(target->space_params), sizeof(gdev_space_params));
max_bitmap = max(target->space_params.MaxBitmap, target->space_params.BufferSpace);
new_target->space_params.BufferSpace = max_bitmap;
new_target->PageHandlerPushed = true;
new_target->ObjectHandlerPushed = true;
if ((code = gdev_prn_open(new_target)) < 0 ||
!PRINTER_IS_CLIST((gx_device_printer *)new_target)) {
gs_free_object(mem->stable_memory, new_target, "pdf14-accum");
goto no_clist_accum;
}
/* Do the initial fillpage into the pdf14-accum device we just created */
dev_proc(new_target, set_graphics_type_tag)(new_target, GS_UNTOUCHED_TAG);
if ((code = gx_remap_concrete_DGray(gs_currentcolorspace_inline((gs_gstate *)pgs),
&pconc_white,
&pdcolor, pgs, new_target, gs_color_select_all,
dev_profile)) < 0)
goto no_clist_accum;
(*dev_proc(new_target, fillpage))(new_target, pgs, &pdcolor);
code = clist_create_compositor(new_target, pdev, (gs_composite_t *)pdf14pct, pgs, mem, NULL);
if (code < 0)
goto no_clist_accum;
pdf14_disable_device((gx_device *)p14dev); /* make the non-clist device forward */
pdf14_close((gx_device *)p14dev); /* and free up the little memory it had */
}
return code;
no_clist_accum:
/* FIXME: We allocated a really small p14dev, but that won't work */
return gs_throw_code(gs_error_Fatal); /* punt for now */
} | 0 | []
| ghostpdl | c432131c3fdb2143e148e8ba88555f7f7a63b25e | 100,407,824,405,364,440,000,000,000,000,000,000,000 | 196 | Bug 699661: Avoid sharing pointers between pdf14 compositors
If a copdevice is triggered when the pdf14 compositor is the device, we make
a copy of the device, then throw an error because, by default we're only allowed
to copy the device prototype - then freeing it calls the finalize, which frees
several pointers shared with the parent.
Make a pdf14 specific finish_copydevice() which NULLs the relevant pointers,
before, possibly, throwing the same error as the default method.
This also highlighted a problem with reopening the X11 devices, where a custom
error handler could be replaced with itself, meaning it also called itself,
and infifite recursion resulted.
Keep a note of if the handler replacement has been done, and don't do it a
second time. |
void intel_pmu_pebs_del(struct perf_event *event)
{
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
struct hw_perf_event *hwc = &event->hw;
bool needed_cb = pebs_needs_sched_cb(cpuc);
cpuc->n_pebs--;
if (hwc->flags & PERF_X86_EVENT_LARGE_PEBS)
cpuc->n_large_pebs--;
if (hwc->flags & PERF_X86_EVENT_PEBS_VIA_PT)
cpuc->n_pebs_via_pt--;
pebs_update_state(needed_cb, cpuc, event, false);
} | 0 | [
"CWE-755"
]
| linux | d88d05a9e0b6d9356e97129d4ff9942d765f46ea | 157,944,731,231,563,210,000,000,000,000,000,000,000 | 14 | perf/x86/intel: Fix a crash caused by zero PEBS status
A repeatable crash can be triggered by the perf_fuzzer on some Haswell
system.
https://lore.kernel.org/lkml/[email protected]/
For some old CPUs (HSW and earlier), the PEBS status in a PEBS record
may be mistakenly set to 0. To minimize the impact of the defect, the
commit was introduced to try to avoid dropping the PEBS record for some
cases. It adds a check in the intel_pmu_drain_pebs_nhm(), and updates
the local pebs_status accordingly. However, it doesn't correct the PEBS
status in the PEBS record, which may trigger the crash, especially for
the large PEBS.
It's possible that all the PEBS records in a large PEBS have the PEBS
status 0. If so, the first get_next_pebs_record_by_bit() in the
__intel_pmu_pebs_event() returns NULL. The at = NULL. Since it's a large
PEBS, the 'count' parameter must > 1. The second
get_next_pebs_record_by_bit() will crash.
Besides the local pebs_status, correct the PEBS status in the PEBS
record as well.
Fixes: 01330d7288e0 ("perf/x86: Allow zero PEBS status with only single active event")
Reported-by: Vince Weaver <[email protected]>
Suggested-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Kan Liang <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected] |
static int nf_tables_dump_obj_done(struct netlink_callback *cb)
{
struct nft_obj_filter *filter = cb->data;
if (filter) {
kfree(filter->table);
kfree(filter);
}
return 0;
} | 0 | [
"CWE-665"
]
| linux | ad9f151e560b016b6ad3280b48e42fa11e1a5440 | 243,292,943,486,385,350,000,000,000,000,000,000,000 | 11 | netfilter: nf_tables: initialize set before expression setup
nft_set_elem_expr_alloc() needs an initialized set if expression sets on
the NFT_EXPR_GC flag. Move set fields initialization before expression
setup.
[4512935.019450] ==================================================================
[4512935.019456] BUG: KASAN: null-ptr-deref in nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019487] Read of size 8 at addr 0000000000000070 by task nft/23532
[4512935.019494] CPU: 1 PID: 23532 Comm: nft Not tainted 5.12.0-rc4+ #48
[...]
[4512935.019502] Call Trace:
[4512935.019505] dump_stack+0x89/0xb4
[4512935.019512] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019536] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019560] kasan_report.cold.12+0x5f/0xd8
[4512935.019566] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019590] nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019615] nf_tables_newset+0xc7f/0x1460 [nf_tables]
Reported-by: [email protected]
Fixes: 65038428b2c6 ("netfilter: nf_tables: allow to specify stateful expression in set definition")
Signed-off-by: Pablo Neira Ayuso <[email protected]> |
htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
int terminate) {
if ((ctxt == NULL) || (ctxt->input == NULL)) {
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
"htmlParseChunk: context error\n", NULL, NULL);
return(XML_ERR_INTERNAL_ERROR);
}
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
size_t cur = ctxt->input->cur - ctxt->input->base;
int res;
res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
if (res < 0) {
ctxt->errNo = XML_PARSER_EOF;
ctxt->disableSAX = 1;
return (XML_PARSER_EOF);
}
xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
#endif
#if 0
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
htmlParseTryOrFinish(ctxt, terminate);
#endif
} else if (ctxt->instate != XML_PARSER_EOF) {
if ((ctxt->input != NULL) && ctxt->input->buf != NULL) {
xmlParserInputBufferPtr in = ctxt->input->buf;
if ((in->encoder != NULL) && (in->buffer != NULL) &&
(in->raw != NULL)) {
int nbchars;
size_t base = xmlBufGetInputBase(in->buffer, ctxt->input);
size_t current = ctxt->input->cur - ctxt->input->base;
nbchars = xmlCharEncInput(in, terminate);
if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"encoder error\n", NULL, NULL);
return(XML_ERR_INVALID_ENCODING);
}
xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
}
}
}
htmlParseTryOrFinish(ctxt, terminate);
if (terminate) {
if ((ctxt->instate != XML_PARSER_EOF) &&
(ctxt->instate != XML_PARSER_EPILOG) &&
(ctxt->instate != XML_PARSER_MISC)) {
ctxt->errNo = XML_ERR_DOCUMENT_END;
ctxt->wellFormed = 0;
}
if (ctxt->instate != XML_PARSER_EOF) {
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
}
ctxt->instate = XML_PARSER_EOF;
}
return((xmlParserErrors) ctxt->errNo);
} | 0 | [
"CWE-119"
]
| libxml2 | e724879d964d774df9b7969fc846605aa1bac54c | 88,852,737,337,559,320,000,000,000,000,000,000,000 | 63 | Fix parsing short unclosed comment uninitialized access
For https://bugzilla.gnome.org/show_bug.cgi?id=746048
The HTML parser was too optimistic when processing comments and
didn't check for the end of the stream on the first 2 characters |
PJ_DEF(pj_status_t) pjmedia_sdp_validate2(const pjmedia_sdp_session *sdp,
pj_bool_t strict)
{
unsigned i;
const pj_str_t STR_RTPMAP = { "rtpmap", 6 };
CHECK( sdp != NULL, PJ_EINVAL);
/* Validate origin line. */
CHECK( sdp->origin.user.slen != 0, PJMEDIA_SDP_EINORIGIN);
CHECK( pj_strcmp2(&sdp->origin.net_type, "IN")==0,
PJMEDIA_SDP_EINORIGIN);
CHECK( pj_strcmp2(&sdp->origin.addr_type, "IP4")==0 ||
pj_strcmp2(&sdp->origin.addr_type, "IP6")==0,
PJMEDIA_SDP_EINORIGIN);
CHECK( sdp->origin.addr.slen != 0, PJMEDIA_SDP_EINORIGIN);
/* Validate subject line. */
CHECK( sdp->name.slen != 0, PJMEDIA_SDP_EINNAME);
/* Ignore start and stop time. */
/* If session level connection info is present, validate it. */
if (sdp->conn) {
pj_status_t status = validate_sdp_conn(sdp->conn);
if (status != PJ_SUCCESS)
return status;
}
/* Validate each media. */
for (i=0; i<sdp->media_count; ++i) {
const pjmedia_sdp_media *m = sdp->media[i];
unsigned j;
/* Validate the m= line. */
CHECK( m->desc.media.slen != 0, PJMEDIA_SDP_EINMEDIA);
CHECK( m->desc.transport.slen != 0, PJMEDIA_SDP_EINMEDIA);
CHECK( m->desc.fmt_count != 0 || m->desc.port==0, PJMEDIA_SDP_ENOFMT);
/* If media level connection info is present, validate it. */
if (m->conn) {
pj_status_t status = validate_sdp_conn(m->conn);
if (status != PJ_SUCCESS)
return status;
}
/* If media doesn't have connection info, then connection info
* must be present in the session.
*/
if (m->conn == NULL) {
if (sdp->conn == NULL)
if (strict || m->desc.port != 0)
return PJMEDIA_SDP_EMISSINGCONN;
}
/* Verify payload type. */
for (j=0; j<m->desc.fmt_count; ++j) {
/* Arrgh noo!! Payload type can be non-numeric!!
* RTC based programs sends "null" for instant messaging!
*/
if (pj_isdigit(*m->desc.fmt[j].ptr)) {
unsigned long pt;
pj_status_t status = pj_strtoul3(&m->desc.fmt[j], &pt, 10);
/* Payload type is between 0 and 127.
*/
CHECK( status == PJ_SUCCESS && pt <= 127, PJMEDIA_SDP_EINPT);
/* If port is not zero, then for each dynamic payload type, an
* rtpmap attribute must be specified.
*/
if (m->desc.port != 0 && pt >= 96) {
const pjmedia_sdp_attr *a;
a = pjmedia_sdp_media_find_attr(m, &STR_RTPMAP,
&m->desc.fmt[j]);
CHECK( a != NULL, PJMEDIA_SDP_EMISSINGRTPMAP);
}
}
}
}
/* Looks good. */
return PJ_SUCCESS;
} | 0 | [
"CWE-121",
"CWE-120",
"CWE-787"
]
| pjproject | 560a1346f87aabe126509bb24930106dea292b00 | 238,159,807,013,912,050,000,000,000,000,000,000,000 | 86 | Merge pull request from GHSA-f5qg-pqcg-765m |
static BOOL update_send_pointer_cached(rdpContext* context,
const POINTER_CACHED_UPDATE* pointer_cached)
{
wStream* s;
rdpRdp* rdp = context->rdp;
BOOL ret;
s = fastpath_update_pdu_init(rdp->fastpath);
if (!s)
return FALSE;
Stream_Write_UINT16(s, pointer_cached->cacheIndex); /* cacheIndex (2 bytes) */
ret = fastpath_send_update_pdu(rdp->fastpath, FASTPATH_UPDATETYPE_CACHED, s, FALSE);
Stream_Release(s);
return ret;
} | 0 | [
"CWE-125"
]
| FreeRDP | f8890a645c221823ac133dbf991f8a65ae50d637 | 256,268,404,563,134,200,000,000,000,000,000,000,000 | 16 | Fixed #6005: Bounds checks in update_read_bitmap_data |
static int mcryptd_hash_final_enqueue(struct ahash_request *req)
{
return mcryptd_hash_enqueue(req, mcryptd_hash_final);
} | 0 | [
"CWE-476",
"CWE-284"
]
| linux | 48a992727d82cb7db076fa15d372178743b1f4cd | 319,476,979,131,099,570,000,000,000,000,000,000,000 | 4 | crypto: mcryptd - Check mcryptd algorithm compatibility
Algorithms not compatible with mcryptd could be spawned by mcryptd
with a direct crypto_alloc_tfm invocation using a "mcryptd(alg)" name
construct. This causes mcryptd to crash the kernel if an arbitrary
"alg" is incompatible and not intended to be used with mcryptd. It is
an issue if AF_ALG tries to spawn mcryptd(alg) to expose it externally.
But such algorithms must be used internally and not be exposed.
We added a check to enforce that only internal algorithms are allowed
with mcryptd at the time mcryptd is spawning an algorithm.
Link: http://marc.info/?l=linux-crypto-vger&m=148063683310477&w=2
Cc: [email protected]
Reported-by: Mikulas Patocka <[email protected]>
Signed-off-by: Tim Chen <[email protected]>
Signed-off-by: Herbert Xu <[email protected]> |
Http::FilterTrailersStatus Context::encodeTrailers(Http::HeaderMap& trailers) {
response_trailers_ = &trailers;
auto result = onResponseTrailers();
response_trailers_ = nullptr;
return result;
} | 0 | [
"CWE-476"
]
| envoy | 8788a3cf255b647fd14e6b5e2585abaaedb28153 | 7,041,047,135,615,125,000,000,000,000,000,000,000 | 6 | 1.4 - Do not call into the VM unless the VM Context has been created. (#24)
* Ensure that the in VM Context is created before onDone is called.
Signed-off-by: John Plevyak <[email protected]>
* Update as per offline discussion.
Signed-off-by: John Plevyak <[email protected]>
* Set in_vm_context_created_ in onNetworkNewConnection.
Signed-off-by: John Plevyak <[email protected]>
* Add guards to other network calls.
Signed-off-by: John Plevyak <[email protected]>
* Fix common/wasm tests.
Signed-off-by: John Plevyak <[email protected]>
* Patch tests.
Signed-off-by: John Plevyak <[email protected]>
* Remove unecessary file from cherry-pick.
Signed-off-by: John Plevyak <[email protected]> |
void CRYPTO_set_dynlock_destroy_callback(void (*func)
(struct CRYPTO_dynlock_value *l, const char *file, int line))
{
dynlock_destroy_callback=func;
} | 0 | [
"CWE-310"
]
| openssl | 9c00a950604aca819cee977f1dcb4b45f2af3aa6 | 174,866,705,678,241,730,000,000,000,000,000,000,000 | 5 | Add and use a constant-time memcmp.
This change adds CRYPTO_memcmp, which compares two vectors of bytes in
an amount of time that's independent of their contents. It also changes
several MAC compares in the code to use this over the standard memcmp,
which may leak information about the size of a matching prefix.
(cherry picked from commit 2ee798880a246d648ecddadc5b91367bee4a5d98)
Conflicts:
crypto/crypto.h
ssl/t1_lib.c |
R_API const char *r_sys_arch_str(int arch) {
int i;
for (i = 0; arch_bit_array[i].name; i++) {
if (arch & arch_bit_array[i].bit) {
return arch_bit_array[i].name;
}
}
return "none";
} | 0 | [
"CWE-78"
]
| radare2 | 04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9 | 278,836,759,225,167,630,000,000,000,000,000,000,000 | 9 | Fix command injection on PDB download (#16966)
* Fix r_sys_mkdirp with absolute path on Windows
* Fix build with --with-openssl
* Use RBuffer in r_socket_http_answer()
* r_socket_http_answer: Fix read for big responses
* Implement r_str_escape_sh()
* Cleanup r_socket_connect() on Windows
* Fix socket being created without a protocol
* Fix socket connect with SSL ##socket
* Use select() in r_socket_ready()
* Fix read failing if received only protocol answer
* Fix double-free
* r_socket_http_get: Fail if req. SSL with no support
* Follow redirects in r_socket_http_answer()
* Fix r_socket_http_get result length with R2_CURL=1
* Also follow redirects
* Avoid using curl for downloading PDBs
* Use r_socket_http_get() on UNIXs
* Use WinINet API on Windows for r_socket_http_get()
* Fix command injection
* Fix r_sys_cmd_str_full output for binary data
* Validate GUID on PDB download
* Pass depth to socket_http_get_recursive()
* Remove 'r_' and '__' from static function names
* Fix is_valid_guid
* Fix for comments |
SYSCALL_DEFINE0(getdtablesize)
{
return sysctl_nr_open;
} | 0 | [
"CWE-703",
"CWE-264",
"CWE-189"
]
| linux | 21c5977a836e399fc710ff2c5367845ed5c2527f | 184,427,057,875,673,560,000,000,000,000,000,000,000 | 4 | alpha: fix several security issues
Fix several security issues in Alpha-specific syscalls. Untested, but
mostly trivial.
1. Signedness issue in osf_getdomainname allows copying out-of-bounds
kernel memory to userland.
2. Signedness issue in osf_sysinfo allows copying large amounts of
kernel memory to userland.
3. Typo (?) in osf_getsysinfo bounds minimum instead of maximum copy
size, allowing copying large amounts of kernel memory to userland.
4. Usage of user pointer in osf_wait4 while under KERNEL_DS allows
privilege escalation via writing return value of sys_wait4 to kernel
memory.
Signed-off-by: Dan Rosenberg <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Matt Turner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
GstRMDemuxStream * stream)
{
GstFlowReturn ret;
GstBuffer *outbuf;
GstMapInfo outmap;
guint packet_size = stream->packet_size;
guint height = stream->subpackets->len;
guint p;
g_assert (stream->height == height);
GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size,
stream->leaf_size, height);
outbuf = gst_buffer_new_and_alloc (height * packet_size);
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
for (p = 0; p < height; ++p) {
GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
if (p == 0) {
GST_BUFFER_DTS (outbuf) = GST_BUFFER_DTS (b);
GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (b);
}
gst_buffer_extract (b, 0, outmap.data + packet_size * p, packet_size);
}
gst_buffer_unmap (outbuf, &outmap);
GST_LOG_OBJECT (rmdemux, "pushing buffer dts %" GST_TIME_FORMAT ", pts %"
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (outbuf)),
GST_TIME_ARGS (GST_BUFFER_PTS (outbuf)));
if (stream->discont) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
stream->discont = FALSE;
}
outbuf = gst_rm_utils_descramble_sipr_buffer (outbuf);
ret = gst_pad_push (stream->pad, outbuf);
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
return ret;
} | 0 | []
| gst-plugins-ugly | 9726aaf78e6643a5955864f444852423de58de29 | 289,537,066,922,473,270,000,000,000,000,000,000,000 | 47 | rmdemux: Make sure we have enough data available when parsing audio/video packets
Otherwise there will be out-of-bounds reads and potential crashes.
Thanks to Natalie Silvanovich for reporting.
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/issues/37
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/merge_requests/75> |
void operator delete[](void* ptr, yaSSL::new_t nt)
{
::operator delete(ptr, nt);
} | 0 | [
"CWE-254"
]
| mysql-server | e7061f7e5a96c66cb2e0bf46bec7f6ff35801a69 | 180,375,925,031,386,200,000,000,000,000,000,000,000 | 4 | Bug #22738607: YASSL FUNCTION X509_NAME_GET_INDEX_BY_NID IS NOT WORKING AS EXPECTED. |
Magick_png_write_raw_profile(const ImageInfo *image_info,png_struct *ping,
png_info *ping_info, unsigned char *profile_type, unsigned char
*profile_description, unsigned char *profile_data, png_uint_32 length)
{
png_textp
text;
register ssize_t
i;
unsigned char
*sp;
png_charp
dp;
png_uint_32
allocated_length,
description_length;
unsigned char
hex[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
if (length > 1)
{
if (LocaleNCompare((char *) profile_type+1, "ng-chunk-",9) == 0)
return;
}
if (image_info->verbose)
{
(void) printf("writing raw profile: type=%s, length=%.20g\n",
(char *) profile_type, (double) length);
}
#if PNG_LIBPNG_VER >= 10400
text=(png_textp) png_malloc(ping,(png_alloc_size_t) sizeof(png_text));
#else
text=(png_textp) png_malloc(ping,(png_size_t) sizeof(png_text));
#endif
description_length=(png_uint_32) strlen((const char *) profile_description);
allocated_length=(png_uint_32) (length*2 + (length >> 5) + 20
+ description_length);
#if PNG_LIBPNG_VER >= 10400
text[0].text=(png_charp) png_malloc(ping,
(png_alloc_size_t) allocated_length);
text[0].key=(png_charp) png_malloc(ping, (png_alloc_size_t) 80);
#else
text[0].text=(png_charp) png_malloc(ping, (png_size_t) allocated_length);
text[0].key=(png_charp) png_malloc(ping, (png_size_t) 80);
#endif
text[0].key[0]='\0';
(void) ConcatenateMagickString(text[0].key,
"Raw profile type ",MaxTextExtent);
(void) ConcatenateMagickString(text[0].key,(const char *) profile_type,62);
sp=profile_data;
dp=text[0].text;
*dp++='\n';
(void) CopyMagickString(dp,(const char *) profile_description,
allocated_length);
dp+=description_length;
*dp++='\n';
(void) FormatLocaleString(dp,allocated_length-
(png_size_t) (dp-text[0].text),"%8lu ",(unsigned long) length);
dp+=8;
for (i=0; i < (ssize_t) length; i++)
{
if (i%36 == 0)
*dp++='\n';
*(dp++)=(char) hex[((*sp >> 4) & 0x0f)];
*(dp++)=(char) hex[((*sp++ ) & 0x0f)];
}
*dp++='\n';
*dp='\0';
text[0].text_length=(png_size_t) (dp-text[0].text);
text[0].compression=image_info->compression == NoCompression ||
(image_info->compression == UndefinedCompression &&
text[0].text_length < 128) ? -1 : 0;
if (text[0].text_length <= allocated_length)
png_set_text(ping,ping_info,text,1);
png_free(ping,text[0].text);
png_free(ping,text[0].key);
png_free(ping,text);
} | 0 | [
"CWE-125"
]
| ImageMagick6 | 34adc98afd5c7e7fb774d2ebdaea39e831c24dce | 322,929,869,811,593,200,000,000,000,000,000,000,000 | 88 | https://github.com/ImageMagick/ImageMagick/issues/1561 |
parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp,
unsigned int *epoch)
{
char *data_offset;
struct create_context *cc;
unsigned int next = 0;
char *name;
data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset);
cc = (struct create_context *)data_offset;
do {
cc = (struct create_context *)((char *)cc + next);
name = le16_to_cpu(cc->NameOffset) + (char *)cc;
if (le16_to_cpu(cc->NameLength) != 4 ||
strncmp(name, "RqLs", 4)) {
next = le32_to_cpu(cc->Next);
continue;
}
return server->ops->parse_lease_buf(cc, epoch);
} while (next != 0);
return 0;
} | 0 | [
"CWE-399"
]
| linux | 18f39e7be0121317550d03e267e3ebd4dbfbb3ce | 279,701,822,630,053,670,000,000,000,000,000,000,000 | 23 | [CIFS] Possible null ptr deref in SMB2_tcon
As Raphael Geissert pointed out, tcon_error_exit can dereference tcon
and there is one path in which tcon can be null.
Signed-off-by: Steve French <[email protected]>
CC: Stable <[email protected]> # v3.7+
Reported-by: Raphael Geissert <[email protected]> |
void trik_del(GF_Box *s)
{
GF_TrickPlayBox *ptr = (GF_TrickPlayBox *) s;
if (ptr == NULL) return;
if (ptr->entries) gf_free(ptr->entries);
gf_free(ptr); | 0 | [
"CWE-400",
"CWE-401"
]
| gpac | d2371b4b204f0a3c0af51ad4e9b491144dd1225c | 309,726,097,447,345,600,000,000,000,000,000,000,000 | 7 | prevent dref memleak on invalid input (#1183) |
static gint conv_sjistoutf8(gchar *outbuf, gint outlen, const gchar *inbuf)
{
gchar *tmpstr;
tmpstr = conv_iconv_strdup(inbuf, CS_SHIFT_JIS, CS_UTF_8);
if (tmpstr) {
strncpy2(outbuf, tmpstr, outlen);
g_free(tmpstr);
return 0;
} else {
strncpy2(outbuf, inbuf, outlen);
return -1;
}
} | 0 | [
"CWE-119"
]
| claws | d390fa07f5548f3173dd9cc13b233db5ce934c82 | 177,197,110,956,537,050,000,000,000,000,000,000,000 | 14 | Make sure we don't run out of the output buffer. Maybe fixes bug #3557 |
virDomainSetSchedulerParameters(virDomainPtr domain,
virTypedParameterPtr params, int nparams)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d", params, nparams);
VIR_TYPED_PARAMS_DEBUG(params, nparams);
virResetLastError();
virCheckDomainReturn(domain, -1);
conn = domain->conn;
virCheckReadOnlyGoto(conn->flags, error);
virCheckNonNullArgGoto(params, error);
virCheckNonNegativeArgGoto(nparams, error);
if (virTypedParameterValidateSet(conn, params, nparams) < 0)
goto error;
if (conn->driver->domainSetSchedulerParameters) {
int ret;
ret = conn->driver->domainSetSchedulerParameters(domain, params, nparams);
if (ret < 0)
goto error;
return ret;
}
virReportUnsupportedError();
error:
virDispatchError(domain->conn);
return -1;
} | 0 | [
"CWE-254"
]
| libvirt | 506e9d6c2d4baaf580d489fff0690c0ff2ff588f | 157,773,057,197,778,430,000,000,000,000,000,000,000 | 34 | virDomainGetTime: Deny on RO connections
We have a policy that if API may end up talking to a guest agent
it should require RW connection. We don't obey the rule in
virDomainGetTime().
Signed-off-by: Michal Privoznik <[email protected]> |
int crypt_token_is_assigned(struct crypt_device *cd, int token, int keyslot)
{
int r;
if ((r = _onlyLUKS2(cd, CRYPT_CD_QUIET | CRYPT_CD_UNRESTRICTED, 0)))
return r;
return LUKS2_token_is_assigned(cd, &cd->u.luks2.hdr, keyslot, token);
} | 0 | [
"CWE-345"
]
| cryptsetup | 0113ac2d889c5322659ad0596d4cfc6da53e356c | 261,393,794,102,092,620,000,000,000,000,000,000,000 | 9 | Fix CVE-2021-4122 - LUKS2 reencryption crash recovery attack
Fix possible attacks against data confidentiality through LUKS2 online
reencryption extension crash recovery.
An attacker can modify on-disk metadata to simulate decryption in
progress with crashed (unfinished) reencryption step and persistently
decrypt part of the LUKS device.
This attack requires repeated physical access to the LUKS device but
no knowledge of user passphrases.
The decryption step is performed after a valid user activates
the device with a correct passphrase and modified metadata.
There are no visible warnings for the user that such recovery happened
(except using the luksDump command). The attack can also be reversed
afterward (simulating crashed encryption from a plaintext) with
possible modification of revealed plaintext.
The problem was caused by reusing a mechanism designed for actual
reencryption operation without reassessing the security impact for new
encryption and decryption operations. While the reencryption requires
calculating and verifying both key digests, no digest was needed to
initiate decryption recovery if the destination is plaintext (no
encryption key). Also, some metadata (like encryption cipher) is not
protected, and an attacker could change it. Note that LUKS2 protects
visible metadata only when a random change occurs. It does not protect
against intentional modification but such modification must not cause
a violation of data confidentiality.
The fix introduces additional digest protection of reencryption
metadata. The digest is calculated from known keys and critical
reencryption metadata. Now an attacker cannot create correct metadata
digest without knowledge of a passphrase for used keyslots.
For more details, see LUKS2 On-Disk Format Specification version 1.1.0. |
compute_pixel_type (XwdLoader *loader)
{
XwdHeader *h = &loader->header;
if (h->bits_per_pixel == 24)
{
if (h->byte_order == 0)
return CHAFA_PIXEL_BGR8;
else
return CHAFA_PIXEL_RGB8;
}
if (h->bits_per_pixel == 32)
{
if (h->byte_order == 0)
return CHAFA_PIXEL_BGRA8_PREMULTIPLIED;
else
return CHAFA_PIXEL_ARGB8_PREMULTIPLIED;
}
return CHAFA_PIXEL_MAX;
} | 0 | [
"CWE-125"
]
| chafa | 56fabfa18a6880b4cb66047fa6557920078048d9 | 297,609,493,527,180,800,000,000,000,000,000,000,000 | 22 | XwdLoader: Fix buffer over-read and improve general robustness
This commit fixes a buffer over-read that could occur due to g_ntohl()
evaluating its argument more than once if at least one of the following
is true:
* Build target is not x86.
* __OPTIMIZE__ is not set during compilation (e.g. -O0 was used).
It also improves robustness more generally and fixes an issue where the
wrong field was being used to calculate the color map size, causing some
image files that were otherwise fine to be rejected.
Reported by @JieyongMa via huntr.dev. |
void WebContents::PostMessage(const std::string& channel,
v8::Local<v8::Value> message_value,
base::Optional<v8::Local<v8::Value>> transfer) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
blink::TransferableMessage transferable_message;
if (!electron::SerializeV8Value(isolate, message_value,
&transferable_message)) {
// SerializeV8Value sets an exception.
return;
}
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (transfer) {
if (!gin::ConvertFromV8(isolate, *transfer, &wrapped_ports)) {
isolate->ThrowException(v8::Exception::Error(
gin::StringToV8(isolate, "Invalid value for transfer")));
return;
}
}
bool threw_exception = false;
transferable_message.ports =
MessagePort::DisentanglePorts(isolate, wrapped_ports, &threw_exception);
if (threw_exception)
return;
content::RenderFrameHost* frame_host = web_contents()->GetMainFrame();
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
electron_renderer->ReceivePostMessage(channel,
std::move(transferable_message));
} | 0 | [
"CWE-200",
"CWE-668"
]
| electron | 07a1c2a3e5845901f7e2eda9506695be58edc73c | 310,654,272,406,280,000,000,000,000,000,000,000,000 | 32 | fix: restrict sendToFrame to same-process frames by default (#26875) |
static void qxl_reset_surfaces(PCIQXLDevice *d)
{
trace_qxl_reset_surfaces(d->id);
d->mode = QXL_MODE_UNDEFINED;
qxl_spice_destroy_surfaces(d, QXL_SYNC);
} | 0 | [
"CWE-476"
]
| qemu | d52680fc932efb8a2f334cc6993e705ed1e31e99 | 231,290,239,613,897,300,000,000,000,000,000,000,000 | 6 | qxl: check release info object
When releasing spice resources in release_resource() routine,
if release info object 'ext.info' is null, it leads to null
pointer dereference. Add check to avoid it.
Reported-by: Bugs SysSec <[email protected]>
Signed-off-by: Prasad J Pandit <[email protected]>
Message-id: [email protected]
Signed-off-by: Gerd Hoffmann <[email protected]> |
int st_select_lex_unit::save_union_explain(Explain_query *output)
{
SELECT_LEX *first= first_select();
if (output->get_union(first->select_number))
return 0; /* Already added */
Explain_union *eu=
new (output->mem_root) Explain_union(output->mem_root,
thd->lex->analyze_stmt);
if (unlikely(!eu))
return 0;
if (with_element && with_element->is_recursive)
eu->is_recursive_cte= true;
if (derived)
eu->connection_type= Explain_node::EXPLAIN_NODE_DERIVED;
/*
Note: Non-merged semi-joins cannot be made out of UNIONs currently, so we
dont ever set EXPLAIN_NODE_NON_MERGED_SJ.
*/
for (SELECT_LEX *sl= first; sl; sl= sl->next_select())
eu->add_select(sl->select_number);
eu->fake_select_type= unit_operation_text[eu->operation= common_op()];
eu->using_filesort= MY_TEST(global_parameters()->order_list.first);
eu->using_tmp= union_needs_tmp_table();
// Save the UNION node
output->add_node(eu);
if (eu->get_select_id() == 1)
output->query_plan_ready();
return 0;
} | 0 | [
"CWE-703"
]
| server | 39feab3cd31b5414aa9b428eaba915c251ac34a2 | 54,335,690,924,505,510,000,000,000,000,000,000,000 | 37 | MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT
IF an INSERT/REPLACE SELECT statement contained an ON expression in the top
level select and this expression used a subquery with a column reference
that could not be resolved then an attempt to resolve this reference as
an outer reference caused a crash of the server. This happened because the
outer context field in the Name_resolution_context structure was not set
to NULL for such references. Rather it pointed to the first element in
the select_stack.
Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select()
method when parsing a SELECT construct.
Approved by Oleksandr Byelkin <[email protected]> |
envcmp(struct envnode *a, struct envnode *b)
{
return strcmp(a->key, b->key);
} | 0 | [
"CWE-200",
"CWE-909"
]
| OpenDoas | 01c658f8c45cb92a343be5f32aa6da70b2032168 | 12,102,128,214,378,628,000,000,000,000,000,000,000 | 4 | redo the environment inheritance to not inherit. it was intended to make life easier, but it can be surprising or even unsafe. instead, reset just about everything to the target user's values. ok deraadt martijn Thanks to Sander Bos in particular for pointing out some nasty edge cases. |
uint32_t CompactProtocolWriter::writeCollectionBegin(
int8_t elemType,
int32_t size) {
uint32_t wsize = 0;
if (size <= 14) {
wsize += writeByte(size << 4 | detail::compact::TTypeToCType[elemType]);
} else {
wsize += writeByte(0xf0 | detail::compact::TTypeToCType[elemType]);
wsize += apache::thrift::util::writeVarint(out_, size);
}
return wsize;
} | 0 | [
"CWE-703",
"CWE-770"
]
| fbthrift | c9a903e5902834e95bbd4ab0e9fa53ba0189f351 | 237,719,688,584,166,750,000,000,000,000,000,000,000 | 12 | Better handling of truncated data when reading strings
Summary:
Currently we read string size and blindly pre-allocate it. This allows malicious attacker to send a few bytes message and cause server to allocate huge amount of memory (>1GB).
This diff changes the logic to check if we have enough data in the buffer before allocating the string.
This is a second part of a fix for CVE-2019-3553.
Reviewed By: vitaut
Differential Revision: D14393393
fbshipit-source-id: e2046d2f5b087d3abc9a9d2c6c107cf088673057 |
psutil_pids(PyObject *self, PyObject *args) {
kinfo_proc *proclist = NULL;
kinfo_proc *orig_address = NULL;
size_t num_processes;
size_t idx;
PyObject *py_pid = NULL;
PyObject *py_retlist = PyList_New(0);
if (py_retlist == NULL)
return NULL;
if (psutil_get_proc_list(&proclist, &num_processes) != 0)
goto error;
// save the address of proclist so we can free it later
orig_address = proclist;
for (idx = 0; idx < num_processes; idx++) {
py_pid = Py_BuildValue("i", proclist->kp_proc.p_pid);
if (! py_pid)
goto error;
if (PyList_Append(py_retlist, py_pid))
goto error;
Py_CLEAR(py_pid);
proclist++;
}
free(orig_address);
return py_retlist;
error:
Py_XDECREF(py_pid);
Py_DECREF(py_retlist);
if (orig_address != NULL)
free(orig_address);
return NULL;
} | 0 | [
"CWE-415"
]
| psutil | 7d512c8e4442a896d56505be3e78f1156f443465 | 3,754,971,621,670,651,000,000,000,000,000,000,000 | 36 | Use Py_CLEAR instead of Py_DECREF to also set the variable to NULL (#1616)
These files contain loops that convert system data into python objects
and during the process they create objects and dereference their
refcounts after they have been added to the resulting list.
However, in case of errors during the creation of those python objects,
the refcount to previously allocated objects is dropped again with
Py_XDECREF, which should be a no-op in case the paramater is NULL. Even
so, in most of these loops the variables pointing to the objects are
never set to NULL, even after Py_DECREF is called at the end of the loop
iteration. This means, after the first iteration, if an error occurs
those python objects will get their refcount dropped two times,
resulting in a possible double-free. |
HTTP_estimate(unsigned nhttp)
{
/* XXX: We trust the structs to size-aligned as necessary */
return (PRNDUP(sizeof(struct http) + sizeof(txt) * nhttp + nhttp));
} | 0 | [
"CWE-703"
]
| varnish-cache | c5fd097e5cce8b461c6443af02b3448baef2491d | 66,748,120,123,968,840,000,000,000,000,000,000,000 | 6 | Do not call http_hdr_flags() on pseudo-headers
In http_EstimateWS(), all headers are passed to the http_isfiltered()
function to calculate how many bytes is needed to serialize the entire
struct http. http_isfiltered() will check the headers for whether they are
going to be filtered out later and if so skip them.
However http_isfiltered() would attempt to treat all elements of struct
http as regular headers with an implicit structure. That does not hold for
the first three pseudo-header entries, which would lead to asserts in
later steps.
This patch skips the filter step for pseudo-headers.
Fixes: #3830 |
void InitHttpParser(Handle<Object> target) {
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(Parser::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->SetClassName(String::NewSymbol("HTTPParser"));
PropertyAttribute attrib = (PropertyAttribute) (ReadOnly | DontDelete);
t->Set(String::NewSymbol("REQUEST"), Integer::New(HTTP_REQUEST), attrib);
t->Set(String::NewSymbol("RESPONSE"), Integer::New(HTTP_RESPONSE), attrib);
NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);
NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish);
NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize);
target->Set(String::NewSymbol("HTTPParser"), t->GetFunction());
on_headers_sym = NODE_PSYMBOL("onHeaders");
on_headers_complete_sym = NODE_PSYMBOL("onHeadersComplete");
on_body_sym = NODE_PSYMBOL("onBody");
on_message_complete_sym = NODE_PSYMBOL("onMessageComplete");
#define X(num, name, string) name##_sym = NODE_PSYMBOL(#string);
HTTP_METHOD_MAP(X)
#undef X
unknown_method_sym = NODE_PSYMBOL("UNKNOWN_METHOD");
method_sym = NODE_PSYMBOL("method");
status_code_sym = NODE_PSYMBOL("statusCode");
http_version_sym = NODE_PSYMBOL("httpVersion");
version_major_sym = NODE_PSYMBOL("versionMajor");
version_minor_sym = NODE_PSYMBOL("versionMinor");
should_keep_alive_sym = NODE_PSYMBOL("shouldKeepAlive");
upgrade_sym = NODE_PSYMBOL("upgrade");
headers_sym = NODE_PSYMBOL("headers");
url_sym = NODE_PSYMBOL("url");
settings.on_message_begin = Parser::on_message_begin;
settings.on_url = Parser::on_url;
settings.on_header_field = Parser::on_header_field;
settings.on_header_value = Parser::on_header_value;
settings.on_headers_complete = Parser::on_headers_complete;
settings.on_body = Parser::on_body;
settings.on_message_complete = Parser::on_message_complete;
} | 0 | []
| node | 7b3fb22290c3b6acb497ca85cf2f1648d75c8154 | 165,771,273,123,805,630,000,000,000,000,000,000,000 | 45 | typo in node_http_parser |
static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
size_t nbytes)
{
ssize_t ret = 0, i;
__u8 tmp[EXTRACT_SIZE];
xfer_secondary_pool(r, nbytes);
nbytes = account(r, nbytes, 0, 0);
while (nbytes) {
if (need_resched()) {
if (signal_pending(current)) {
if (ret == 0)
ret = -ERESTARTSYS;
break;
}
schedule();
}
extract_buf(r, tmp);
i = min_t(int, nbytes, EXTRACT_SIZE);
if (copy_to_user(buf, tmp, i)) {
ret = -EFAULT;
break;
}
nbytes -= i;
buf += i;
ret += i;
}
/* Wipe data just returned from memory */
memset(tmp, 0, sizeof(tmp));
return ret;
} | 0 | [
"CWE-310"
]
| linux-2.6 | 8a0a9bd4db63bc45e3017bedeafbd88d0eb84d02 | 327,001,153,228,479,520,000,000,000,000,000,000,000 | 36 | random: make get_random_int() more random
It's a really simple patch that basically just open-codes the current
"secure_ip_id()" call, but when open-coding it we now use a _static_
hashing area, so that it gets updated every time.
And to make sure somebody can't just start from the same original seed of
all-zeroes, and then do the "half_md4_transform()" over and over until
they get the same sequence as the kernel has, each iteration also mixes in
the same old "current->pid + jiffies" we used - so we should now have a
regular strong pseudo-number generator, but we also have one that doesn't
have a single seed.
Note: the "pid + jiffies" is just meant to be a tiny tiny bit of noise. It
has no real meaning. It could be anything. I just picked the previous
seed, it's just that now we keep the state in between calls and that will
feed into the next result, and that should make all the difference.
I made that hash be a per-cpu data just to avoid cache-line ping-pong:
having multiple CPU's write to the same data would be fine for randomness,
and add yet another layer of chaos to it, but since get_random_int() is
supposed to be a fast interface I did it that way instead. I considered
using "__raw_get_cpu_var()" to avoid any preemption overhead while still
getting the hash be _mostly_ ping-pong free, but in the end good taste won
out.
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
}static inline void WriteResourceLong(unsigned char *p,
const unsigned int quantum)
{
unsigned char
buffer[4];
buffer[0]=(unsigned char) (quantum >> 24);
buffer[1]=(unsigned char) (quantum >> 16);
buffer[2]=(unsigned char) (quantum >> 8);
buffer[3]=(unsigned char) quantum;
(void) CopyMagickMemory(p,buffer,4);
} | 1 | [
"CWE-190",
"CWE-125"
]
| ImageMagick | d8ab7f046587f2e9f734b687ba7e6e10147c294b | 15,335,645,506,443,241,000,000,000,000,000,000,000 | 12 | Improve checking of EXIF profile to prevent integer overflow (bug report from Ibrahim el-sayed) |
static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)
{
struct path realpath;
struct inode *realinode;
ovl_path_real(dentry, &realpath);
realinode = realpath.dentry->d_inode;
if (!realinode->i_op->readlink)
return -EINVAL;
touch_atime(&realpath);
return realinode->i_op->readlink(realpath.dentry, buf, bufsiz);
} | 0 | [
"CWE-284",
"CWE-264"
]
| linux | acff81ec2c79492b180fade3c2894425cd35a545 | 93,736,251,918,384,120,000,000,000,000,000,000,000 | 15 | ovl: fix permission checking for setattr
[Al Viro] The bug is in being too enthusiastic about optimizing ->setattr()
away - instead of "copy verbatim with metadata" + "chmod/chown/utimes"
(with the former being always safe and the latter failing in case of
insufficient permissions) it tries to combine these two. Note that copyup
itself will have to do ->setattr() anyway; _that_ is where the elevated
capabilities are right. Having these two ->setattr() (one to set verbatim
copy of metadata, another to do what overlayfs ->setattr() had been asked
to do in the first place) combined is where it breaks.
Signed-off-by: Miklos Szeredi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Al Viro <[email protected]> |
static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp,
u8 feature_index, u8 *nameLength)
{
struct hidpp_report response;
int ret;
ret = hidpp_send_fap_command_sync(hidpp, feature_index,
CMD_GET_DEVICE_NAME_TYPE_GET_COUNT, NULL, 0, &response);
if (ret > 0) {
hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
__func__, ret);
return -EPROTO;
}
if (ret)
return ret;
*nameLength = response.fap.params[0];
return ret;
} | 0 | [
"CWE-787"
]
| linux | d9d4b1e46d9543a82c23f6df03f4ad697dab361b | 223,170,775,983,640,860,000,000,000,000,000,000,000 | 21 | HID: Fix assumption that devices have inputs
The syzbot fuzzer found a slab-out-of-bounds write bug in the hid-gaff
driver. The problem is caused by the driver's assumption that the
device must have an input report. While this will be true for all
normal HID input devices, a suitably malicious device can violate the
assumption.
The same assumption is present in over a dozen other HID drivers.
This patch fixes them by checking that the list of hid_inputs for the
hid_device is nonempty before allowing it to be used.
Reported-and-tested-by: [email protected]
Signed-off-by: Alan Stern <[email protected]>
CC: <[email protected]>
Signed-off-by: Benjamin Tissoires <[email protected]> |
ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, int name_length, double value, int access_type TSRMLS_DC) /* {{{ */
{
zval *property;
if (ce->type & ZEND_INTERNAL_CLASS) {
ALLOC_PERMANENT_ZVAL(property);
} else {
ALLOC_ZVAL(property);
}
INIT_PZVAL(property);
ZVAL_DOUBLE(property, value);
return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC);
} | 0 | [
"CWE-416"
]
| php-src | 0e6fe3a4c96be2d3e88389a5776f878021b4c59f | 95,407,904,186,414,920,000,000,000,000,000,000,000 | 13 | Fix bug #73147: Use After Free in PHP7 unserialize() |
write_viminfo(char_u *file, int forceit)
{
char_u *fname;
FILE *fp_in = NULL; // input viminfo file, if any
FILE *fp_out = NULL; // output viminfo file
char_u *tempname = NULL; // name of temp viminfo file
stat_T st_new; // mch_stat() of potential new file
stat_T st_old; // mch_stat() of existing viminfo file
#if defined(UNIX) || defined(VMS)
mode_t umask_save;
#endif
#ifdef UNIX
int shortname = FALSE; // use 8.3 file name
#endif
#ifdef MSWIN
int hidden = FALSE;
#endif
if (no_viminfo())
return;
fname = viminfo_filename(file); // may set to default if NULL
if (fname == NULL)
return;
fp_in = mch_fopen((char *)fname, READBIN);
if (fp_in == NULL)
{
int fd;
// if it does exist, but we can't read it, don't try writing
if (mch_stat((char *)fname, &st_new) == 0)
goto end;
// Create the new .viminfo non-accessible for others, because it may
// contain text from non-accessible documents. It is up to the user to
// widen access (e.g. to a group). This may also fail if there is a
// race condition, then just give up.
fd = mch_open((char *)fname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
if (fd < 0)
goto end;
fp_out = fdopen(fd, WRITEBIN);
}
else
{
// There is an existing viminfo file. Create a temporary file to
// write the new viminfo into, in the same directory as the
// existing viminfo file, which will be renamed once all writing is
// successful.
if (mch_fstat(fileno(fp_in), &st_old) < 0
|| S_ISDIR(st_old.st_mode)
#ifdef UNIX
// For Unix we check the owner of the file. It's not very nice
// to overwrite a user's viminfo file after a "su root", with a
// viminfo file that the user can't read.
|| (getuid() != ROOT_UID
&& !(st_old.st_uid == getuid()
? (st_old.st_mode & 0200)
: (st_old.st_gid == getgid()
? (st_old.st_mode & 0020)
: (st_old.st_mode & 0002))))
#endif
)
{
int tt = msg_didany;
// avoid a wait_return for this message, it's annoying
semsg(_(e_viminfo_file_is_not_writable_str), fname);
msg_didany = tt;
fclose(fp_in);
goto end;
}
#ifdef MSWIN
// Get the file attributes of the existing viminfo file.
hidden = mch_ishidden(fname);
#endif
// Make tempname, find one that does not exist yet.
// Beware of a race condition: If someone logs out and all Vim
// instances exit at the same time a temp file might be created between
// stat() and open(). Use mch_open() with O_EXCL to avoid that.
// May try twice: Once normal and once with shortname set, just in
// case somebody puts his viminfo file in an 8.3 filesystem.
for (;;)
{
int next_char = 'z';
char_u *wp;
tempname = buf_modname(
#ifdef UNIX
shortname,
#else
FALSE,
#endif
fname,
#ifdef VMS
(char_u *)"-tmp",
#else
(char_u *)".tmp",
#endif
FALSE);
if (tempname == NULL) // out of memory
break;
// Try a series of names. Change one character, just before
// the extension. This should also work for an 8.3
// file name, when after adding the extension it still is
// the same file as the original.
wp = tempname + STRLEN(tempname) - 5;
if (wp < gettail(tempname)) // empty file name?
wp = gettail(tempname);
for (;;)
{
// Check if tempfile already exists. Never overwrite an
// existing file!
if (mch_stat((char *)tempname, &st_new) == 0)
{
#ifdef UNIX
// Check if tempfile is same as original file. May happen
// when modname() gave the same file back. E.g. silly
// link, or file name-length reached. Try again with
// shortname set.
if (!shortname && st_new.st_dev == st_old.st_dev
&& st_new.st_ino == st_old.st_ino)
{
VIM_CLEAR(tempname);
shortname = TRUE;
break;
}
#endif
}
else
{
// Try creating the file exclusively. This may fail if
// another Vim tries to do it at the same time.
#ifdef VMS
// fdopen() fails for some reason
umask_save = umask(077);
fp_out = mch_fopen((char *)tempname, WRITEBIN);
(void)umask(umask_save);
#else
int fd;
// Use mch_open() to be able to use O_NOFOLLOW and set file
// protection:
// Unix: same as original file, but strip s-bit. Reset
// umask to avoid it getting in the way.
// Others: r&w for user only.
# ifdef UNIX
umask_save = umask(0);
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW,
(int)((st_old.st_mode & 0777) | 0600));
(void)umask(umask_save);
# else
fd = mch_open((char *)tempname,
O_CREAT|O_EXTRA|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600);
# endif
if (fd < 0)
{
fp_out = NULL;
# ifdef EEXIST
// Avoid trying lots of names while the problem is lack
// of permission, only retry if the file already
// exists.
if (errno != EEXIST)
break;
# endif
}
else
fp_out = fdopen(fd, WRITEBIN);
#endif // VMS
if (fp_out != NULL)
break;
}
// Assume file exists, try again with another name.
if (next_char == 'a' - 1)
{
// They all exist? Must be something wrong! Don't write
// the viminfo file then.
semsg(_(e_too_many_viminfo_temp_files_like_str), tempname);
break;
}
*wp = next_char;
--next_char;
}
if (tempname != NULL)
break;
// continue if shortname was set
}
#if defined(UNIX) && defined(HAVE_FCHOWN)
if (tempname != NULL && fp_out != NULL)
{
stat_T tmp_st;
// Make sure the original owner can read/write the tempfile and
// otherwise preserve permissions, making sure the group matches.
if (mch_stat((char *)tempname, &tmp_st) >= 0)
{
if (st_old.st_uid != tmp_st.st_uid)
// Changing the owner might fail, in which case the
// file will now be owned by the current user, oh well.
vim_ignored = fchown(fileno(fp_out), st_old.st_uid, -1);
if (st_old.st_gid != tmp_st.st_gid
&& fchown(fileno(fp_out), -1, st_old.st_gid) == -1)
// can't set the group to what it should be, remove
// group permissions
(void)mch_setperm(tempname, 0600);
}
else
// can't stat the file, set conservative permissions
(void)mch_setperm(tempname, 0600);
}
#endif
}
// Check if the new viminfo file can be written to.
if (fp_out == NULL)
{
semsg(_(e_cant_write_viminfo_file_str),
(fp_in == NULL || tempname == NULL) ? fname : tempname);
if (fp_in != NULL)
fclose(fp_in);
goto end;
}
if (p_verbose > 0)
{
verbose_enter();
smsg(_("Writing viminfo file \"%s\""), fname);
verbose_leave();
}
viminfo_errcnt = 0;
do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
if (fclose(fp_out) == EOF)
++viminfo_errcnt;
if (fp_in != NULL)
{
fclose(fp_in);
// In case of an error keep the original viminfo file. Otherwise
// rename the newly written file. Give an error if that fails.
if (viminfo_errcnt == 0)
{
if (vim_rename(tempname, fname) == -1)
{
++viminfo_errcnt;
semsg(_(e_cant_rename_viminfo_file_to_str), fname);
}
# ifdef MSWIN
// If the viminfo file was hidden then also hide the new file.
else if (hidden)
mch_hide(fname);
# endif
}
if (viminfo_errcnt > 0)
mch_remove(tempname);
}
end:
vim_free(fname);
vim_free(tempname);
} | 0 | [
"CWE-416"
]
| vim | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | 257,101,428,589,575,650,000,000,000,000,000,000,000 | 270 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. |
static inline unsigned int tok_check_len(size_t len)
{
if (unlikely(len > MAX_TEXT))
nasm_fatal("impossibly large token");
return len;
} | 0 | []
| nasm | 6299a3114ce0f3acd55d07de201a8ca2f0a83059 | 33,195,227,481,847,204,000,000,000,000,000,000,000 | 7 | BR 3392708: fix NULL pointer reference for invalid %stacksize
After issuing an error message for a missing %stacksize argument, need
to quit rather than continuing to try to access the pointer.
Fold uses of tok_text() while we are at it.
Reported-by: Suhwan <[email protected]>
Signed-off-by: H. Peter Anvin (Intel) <[email protected]> |
xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
{
xmlSchemaPSVIIDCBindingPtr bind; /* IDC bindings of the current node. */
xmlSchemaPSVIIDCBindingPtr *parTable, parBind = NULL; /* parent IDC bindings. */
xmlSchemaPSVIIDCNodePtr node, parNode = NULL, *dupls, *parNodes; /* node-table entries. */
xmlSchemaIDCAugPtr aidc;
int i, j, k, ret = 0, nbFields, oldNum, oldDupls;
bind = vctxt->inode->idcTable;
if (bind == NULL) {
/* Fine, no table, no bubbles. */
return (0);
}
parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable);
/*
* Walk all bindings; create new or add to existing bindings.
* Remove duplicate key-sequences.
*/
while (bind != NULL) {
if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls))
goto next_binding;
/*
* Check if the key/unique IDC table needs to be bubbled.
*/
if (! vctxt->createIDCNodeTables) {
aidc = vctxt->aidcs;
do {
if (aidc->def == bind->definition) {
if ((aidc->keyrefDepth == -1) ||
(aidc->keyrefDepth >= vctxt->depth)) {
goto next_binding;
}
break;
}
aidc = aidc->next;
} while (aidc != NULL);
}
if (parTable != NULL)
parBind = *parTable;
/*
* Search a matching parent binding for the
* IDC definition.
*/
while (parBind != NULL) {
if (parBind->definition == bind->definition)
break;
parBind = parBind->next;
}
if (parBind != NULL) {
/*
* Compare every node-table entry of the child node,
* i.e. the key-sequence within, ...
*/
oldNum = parBind->nbNodes; /* Skip newly added items. */
if (! WXS_ILIST_IS_EMPTY(parBind->dupls)) {
oldDupls = parBind->dupls->nbItems;
dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items;
} else {
dupls = NULL;
oldDupls = 0;
}
parNodes = parBind->nodeTable;
nbFields = bind->definition->nbFields;
for (i = 0; i < bind->nbNodes; i++) {
node = bind->nodeTable[i];
if (node == NULL)
continue;
/*
* ...with every key-sequence of the parent node, already
* evaluated to be a duplicate key-sequence.
*/
if (oldDupls) {
j = 0;
while (j < oldDupls) {
if (nbFields == 1) {
ret = xmlSchemaAreValuesEqual(
node->keys[0]->val,
dupls[j]->keys[0]->val);
if (ret == -1)
goto internal_error;
if (ret == 0) {
j++;
continue;
}
} else {
parNode = dupls[j];
for (k = 0; k < nbFields; k++) {
ret = xmlSchemaAreValuesEqual(
node->keys[k]->val,
parNode->keys[k]->val);
if (ret == -1)
goto internal_error;
if (ret == 0)
break;
}
}
if (ret == 1)
/* Duplicate found. */
break;
j++;
}
if (j != oldDupls) {
/* Duplicate found. Skip this entry. */
continue;
}
}
/*
* ... and with every key-sequence of the parent node.
*/
if (oldNum) {
j = 0;
while (j < oldNum) {
parNode = parNodes[j];
if (nbFields == 1) {
ret = xmlSchemaAreValuesEqual(
node->keys[0]->val,
parNode->keys[0]->val);
if (ret == -1)
goto internal_error;
if (ret == 0) {
j++;
continue;
}
} else {
for (k = 0; k < nbFields; k++) {
ret = xmlSchemaAreValuesEqual(
node->keys[k]->val,
parNode->keys[k]->val);
if (ret == -1)
goto internal_error;
if (ret == 0)
break;
}
}
if (ret == 1)
/* Duplicate found. */
break;
j++;
}
if (j != oldNum) {
/*
* Handle duplicates. Move the duplicate in
* the parent's node-table to the list of
* duplicates.
*/
oldNum--;
parBind->nbNodes--;
/*
* Move last old item to pos of duplicate.
*/
parNodes[j] = parNodes[oldNum];
if (parBind->nbNodes != oldNum) {
/*
* If new items exist, move last new item to
* last of old items.
*/
parNodes[oldNum] =
parNodes[parBind->nbNodes];
}
if (parBind->dupls == NULL) {
parBind->dupls = xmlSchemaItemListCreate();
if (parBind->dupls == NULL)
goto internal_error;
}
xmlSchemaItemListAdd(parBind->dupls, parNode);
} else {
/*
* Add the node-table entry (node and key-sequence) of
* the child node to the node table of the parent node.
*/
if (parBind->nodeTable == NULL) {
parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
xmlSchemaVErrMemory(NULL,
"allocating IDC list of node-table items", NULL);
goto internal_error;
}
parBind->sizeNodes = 1;
} else if (parBind->nbNodes >= parBind->sizeNodes) {
parBind->sizeNodes *= 2;
parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
xmlRealloc(parBind->nodeTable, parBind->sizeNodes *
sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
xmlSchemaVErrMemory(NULL,
"re-allocating IDC list of node-table items", NULL);
goto internal_error;
}
}
parNodes = parBind->nodeTable;
/*
* Append the new node-table entry to the 'new node-table
* entries' section.
*/
parNodes[parBind->nbNodes++] = node;
}
}
}
} else {
/*
* No binding for the IDC was found: create a new one and
* copy all node-tables.
*/
parBind = xmlSchemaIDCNewBinding(bind->definition);
if (parBind == NULL)
goto internal_error;
/*
* TODO: Hmm, how to optimize the initial number of
* allocated entries?
*/
if (bind->nbNodes != 0) {
/*
* Add all IDC node-table entries.
*/
if (! vctxt->psviExposeIDCNodeTables) {
/*
* Just move the entries.
* NOTE: this is quite save here, since
* all the keyref lookups have already been
* performed.
*/
parBind->nodeTable = bind->nodeTable;
bind->nodeTable = NULL;
parBind->sizeNodes = bind->sizeNodes;
bind->sizeNodes = 0;
parBind->nbNodes = bind->nbNodes;
bind->nbNodes = 0;
} else {
/*
* Copy the entries.
*/
parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
xmlMalloc(bind->nbNodes *
sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
xmlSchemaVErrMemory(NULL,
"allocating an array of IDC node-table "
"items", NULL);
xmlSchemaIDCFreeBinding(parBind);
goto internal_error;
}
parBind->sizeNodes = bind->nbNodes;
parBind->nbNodes = bind->nbNodes;
memcpy(parBind->nodeTable, bind->nodeTable,
bind->nbNodes * sizeof(xmlSchemaPSVIIDCNodePtr));
}
}
if (bind->dupls) {
/*
* Move the duplicates.
*/
if (parBind->dupls != NULL)
xmlSchemaItemListFree(parBind->dupls);
parBind->dupls = bind->dupls;
bind->dupls = NULL;
}
if (parTable != NULL) {
if (*parTable == NULL)
*parTable = parBind;
else {
parBind->next = *parTable;
*parTable = parBind;
}
}
}
next_binding:
bind = bind->next;
}
return (0);
internal_error:
return(-1);
} | 0 | [
"CWE-134"
]
| libxml2 | 4472c3a5a5b516aaf59b89be602fbce52756c3e9 | 119,914,925,445,856,850,000,000,000,000,000,000,000 | 286 | Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029
Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports. |
int jpc_floorlog2(int x)
{
int y;
/* The argument must be positive. */
assert(x > 0);
y = 0;
while (x > 1) {
x >>= 1;
++y;
}
return y;
} | 0 | [
"CWE-617"
]
| jasper | e6c8d5a838b49f94616be14753aa5c89d64605b5 | 137,014,172,159,175,940,000,000,000,000,000,000,000 | 14 | jpc_math: split jpc_firstone() in int/jpc_fix_t overloads
Fixes CVE-2018-9055 (denial of service via a reachable assertion due
to integer overflow).
Based on a patch from Fridrich Strba <[email protected]>. Instead of
switching to `int_fast32_t`, this patch splits jpc_firstone() into two
overloads, one for `int` and one for `jpc_fix_t`. This is safer
against future changes on `jpc_fix_t`. To avoid the overhead of 64
bit integer math on 32 bit CPUs, this leaves the `int` overload
around.
Closes https://github.com/jasper-maint/jasper/issues/9 |
static uint8_t individual_channel_stream(NeAACDecStruct *hDecoder, element *ele,
bitfile *ld, ic_stream *ics, uint8_t scal_flag,
int16_t *spec_data)
{
uint8_t result;
result = side_info(hDecoder, ele, ld, ics, scal_flag);
if (result > 0)
return result;
if (hDecoder->object_type >= ER_OBJECT_START)
{
if (ics->tns_data_present)
tns_data(ics, &(ics->tns), ld);
}
#ifdef DRM
/* CRC check */
if (hDecoder->object_type == DRM_ER_LC)
{
if ((result = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0)
return result;
}
#endif
#ifdef ERROR_RESILIENCE
if (hDecoder->aacSpectralDataResilienceFlag)
{
/* error resilient spectral data decoding */
if ((result = reordered_spectral_data(hDecoder, ics, ld, spec_data)) > 0)
{
return result;
}
} else {
#endif
/* decode the spectral data */
if ((result = spectral_data(hDecoder, ics, ld, spec_data)) > 0)
{
return result;
}
#ifdef ERROR_RESILIENCE
}
#endif
/* pulse coding reconstruction */
if (ics->pulse_data_present)
{
if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
{
if ((result = pulse_decode(ics, spec_data, hDecoder->frameLength)) > 0)
return result;
} else {
return 2; /* pulse coding not allowed for short blocks */
}
}
return 0;
} | 0 | [
"CWE-119",
"CWE-787"
]
| faad2 | 942c3e0aee748ea6fe97cb2c1aa5893225316174 | 300,671,632,584,501,800,000,000,000,000,000,000,000 | 58 | Fix a couple buffer overflows
https://hackerone.com/reports/502816
https://hackerone.com/reports/507858
https://github.com/videolan/vlc/blob/master/contrib/src/faad2/faad2-fix-overflows.patch |
virDomainDefFormatFeatures(virBufferPtr buf,
virDomainDefPtr def)
{
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
size_t i;
for (i = 0; i < VIR_DOMAIN_FEATURE_LAST; i++) {
g_auto(virBuffer) tmpAttrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) tmpChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
const char *name = virDomainFeatureTypeToString(i);
size_t j;
switch ((virDomainFeature) i) {
case VIR_DOMAIN_FEATURE_ACPI:
case VIR_DOMAIN_FEATURE_PAE:
case VIR_DOMAIN_FEATURE_VIRIDIAN:
case VIR_DOMAIN_FEATURE_PRIVNET:
/* NOTE: This is for old style <opt/> booleans. New XML
* should use the explicit state=on|off output below */
switch ((virTristateSwitch) def->features[i]) {
case VIR_TRISTATE_SWITCH_ABSENT:
break;
case VIR_TRISTATE_SWITCH_ON:
virBufferAsprintf(&childBuf, "<%s/>\n", name);
break;
case VIR_TRISTATE_SWITCH_LAST:
case VIR_TRISTATE_SWITCH_OFF:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected state of feature '%s'"), name);
return -1;
break;
}
break;
case VIR_DOMAIN_FEATURE_VMCOREINFO:
case VIR_DOMAIN_FEATURE_HAP:
case VIR_DOMAIN_FEATURE_PMU:
case VIR_DOMAIN_FEATURE_PVSPINLOCK:
case VIR_DOMAIN_FEATURE_VMPORT:
case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
switch ((virTristateSwitch) def->features[i]) {
case VIR_TRISTATE_SWITCH_LAST:
case VIR_TRISTATE_SWITCH_ABSENT:
break;
case VIR_TRISTATE_SWITCH_ON:
virBufferAsprintf(&childBuf, "<%s state='on'/>\n", name);
break;
case VIR_TRISTATE_SWITCH_OFF:
virBufferAsprintf(&childBuf, "<%s state='off'/>\n", name);
break;
}
break;
case VIR_DOMAIN_FEATURE_SMM:
if (def->features[i] == VIR_TRISTATE_SWITCH_ABSENT)
break;
virBufferAsprintf(&tmpAttrBuf, " state='%s'",
virTristateSwitchTypeToString(def->features[i]));
if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
def->tseg_specified) {
const char *unit;
unsigned long long short_size = virFormatIntPretty(def->tseg_size,
&unit);
virBufferAsprintf(&tmpChildBuf, "<tseg unit='%s'>%llu</tseg>\n",
unit, short_size);
}
virXMLFormatElement(&childBuf, "smm", &tmpAttrBuf, &tmpChildBuf);
break;
case VIR_DOMAIN_FEATURE_APIC:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, "<apic");
if (def->apic_eoi) {
virBufferAsprintf(&childBuf, " eoi='%s'",
virTristateSwitchTypeToString(def->apic_eoi));
}
virBufferAddLit(&childBuf, "/>\n");
}
break;
case VIR_DOMAIN_FEATURE_HYPERV:
if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
break;
virBufferAddLit(&childBuf, "<hyperv>\n");
virBufferAdjustIndent(&childBuf, 2);
for (j = 0; j < VIR_DOMAIN_HYPERV_LAST; j++) {
if (def->hyperv_features[j] == VIR_TRISTATE_SWITCH_ABSENT)
continue;
virBufferAsprintf(&childBuf, "<%s state='%s'",
virDomainHypervTypeToString(j),
virTristateSwitchTypeToString(
def->hyperv_features[j]));
switch ((virDomainHyperv) j) {
case VIR_DOMAIN_HYPERV_RELAXED:
case VIR_DOMAIN_HYPERV_VAPIC:
case VIR_DOMAIN_HYPERV_VPINDEX:
case VIR_DOMAIN_HYPERV_RUNTIME:
case VIR_DOMAIN_HYPERV_SYNIC:
case VIR_DOMAIN_HYPERV_RESET:
case VIR_DOMAIN_HYPERV_FREQUENCIES:
case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
case VIR_DOMAIN_HYPERV_TLBFLUSH:
case VIR_DOMAIN_HYPERV_IPI:
case VIR_DOMAIN_HYPERV_EVMCS:
virBufferAddLit(&childBuf, "/>\n");
break;
case VIR_DOMAIN_HYPERV_SPINLOCKS:
if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, "/>\n");
break;
}
virBufferAsprintf(&childBuf, " retries='%d'/>\n",
def->hyperv_spinlocks);
break;
case VIR_DOMAIN_HYPERV_STIMER:
if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, "/>\n");
break;
}
if (def->hyperv_stimer_direct == VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, ">\n");
virBufferAdjustIndent(&childBuf, 2);
virBufferAddLit(&childBuf, "<direct state='on'/>\n");
virBufferAdjustIndent(&childBuf, -2);
virBufferAddLit(&childBuf, "</stimer>\n");
} else {
virBufferAddLit(&childBuf, "/>\n");
}
break;
case VIR_DOMAIN_HYPERV_VENDOR_ID:
if (def->hyperv_features[j] != VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, "/>\n");
break;
}
virBufferEscapeString(&childBuf, " value='%s'/>\n",
def->hyperv_vendor_id);
break;
/* coverity[dead_error_begin] */
case VIR_DOMAIN_HYPERV_LAST:
break;
}
}
virBufferAdjustIndent(&childBuf, -2);
virBufferAddLit(&childBuf, "</hyperv>\n");
break;
case VIR_DOMAIN_FEATURE_KVM:
if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
break;
virBufferAddLit(&childBuf, "<kvm>\n");
virBufferAdjustIndent(&childBuf, 2);
for (j = 0; j < VIR_DOMAIN_KVM_LAST; j++) {
switch ((virDomainKVM) j) {
case VIR_DOMAIN_KVM_HIDDEN:
case VIR_DOMAIN_KVM_DEDICATED:
if (def->kvm_features[j])
virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
virDomainKVMTypeToString(j),
virTristateSwitchTypeToString(
def->kvm_features[j]));
break;
/* coverity[dead_error_begin] */
case VIR_DOMAIN_KVM_LAST:
break;
}
}
virBufferAdjustIndent(&childBuf, -2);
virBufferAddLit(&childBuf, "</kvm>\n");
break;
case VIR_DOMAIN_FEATURE_CAPABILITIES:
for (j = 0; j < VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST; j++) {
if (def->caps_features[j] != VIR_TRISTATE_SWITCH_ABSENT)
virBufferAsprintf(&tmpChildBuf, "<%s state='%s'/>\n",
virDomainProcessCapsFeatureTypeToString(j),
virTristateSwitchTypeToString(def->caps_features[j]));
}
/* the 'default' policy should be printed if any capability is present */
if (def->features[i] != VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT ||
virBufferUse(&tmpChildBuf))
virBufferAsprintf(&tmpAttrBuf, " policy='%s'",
virDomainCapabilitiesPolicyTypeToString(def->features[i]));
virXMLFormatElement(&childBuf, "capabilities", &tmpAttrBuf, &tmpChildBuf);
break;
case VIR_DOMAIN_FEATURE_GIC:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
virBufferAddLit(&childBuf, "<gic");
if (def->gic_version != VIR_GIC_VERSION_NONE)
virBufferAsprintf(&childBuf, " version='%s'",
virGICVersionTypeToString(def->gic_version));
virBufferAddLit(&childBuf, "/>\n");
}
break;
case VIR_DOMAIN_FEATURE_IOAPIC:
if (def->features[i] == VIR_DOMAIN_IOAPIC_NONE)
break;
virBufferAsprintf(&childBuf, "<ioapic driver='%s'/>\n",
virDomainIOAPICTypeToString(def->features[i]));
break;
case VIR_DOMAIN_FEATURE_HPT:
if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
break;
if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE) {
virBufferAsprintf(&tmpAttrBuf,
" resizing='%s'",
virDomainHPTResizingTypeToString(def->hpt_resizing));
}
if (def->hpt_maxpagesize > 0) {
virBufferAsprintf(&tmpChildBuf,
"<maxpagesize unit='KiB'>%llu</maxpagesize>\n",
def->hpt_maxpagesize);
}
virXMLFormatElement(&childBuf, "hpt", &tmpAttrBuf, &tmpChildBuf);
break;
case VIR_DOMAIN_FEATURE_MSRS:
if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
break;
virBufferAsprintf(&childBuf, "<msrs unknown='%s'/>\n",
virDomainMsrsUnknownTypeToString(def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN]));
break;
/* coverity[dead_error_begin] */
case VIR_DOMAIN_FEATURE_LAST:
break;
}
}
virXMLFormatElement(buf, "features", NULL, &childBuf);
return 0;
} | 0 | [
"CWE-212"
]
| libvirt | a5b064bf4b17a9884d7d361733737fb614ad8979 | 80,055,173,223,940,260,000,000,000,000,000,000,000 | 263 | conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used
Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410
(v6.1.0-122-g3b076391be) we support http cookies. Since they may contain
somewhat sensitive information we should not format them into the XML
unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted.
Reported-by: Han Han <[email protected]>
Signed-off-by: Peter Krempa <[email protected]>
Reviewed-by: Erik Skultety <[email protected]> |
gdev_xps_stroke_path(gx_device * dev, const gs_gstate * pgs, gx_path * ppath,
const gx_stroke_params * params,
const gx_drawing_color * pdcolor, const gx_clip_path * pcpath)
{
if (gx_path_is_void(ppath)) {
return 0;
}
return gdev_vector_stroke_path(dev, pgs, ppath, params, pdcolor, pcpath);
} | 0 | []
| ghostpdl | 94d8955cb7725eb5f3557ddc02310c76124fdd1a | 234,776,053,388,399,570,000,000,000,000,000,000,000 | 9 | Bug 701818: better handling of error during PS/PDF image
In the xps device, if an error occurred after xps_begin_image() but before
xps_image_end_image(), *if* the Postscript had called 'restore' as part of the
error handling, the image enumerator would have been freed (by the restore)
despite the xps device still holding a reference to it.
Simply changing to an allocator unaffected save/restore doesn't work because
the enumerator holds references to other objects (graphics state, color space,
possibly others) whose lifespans are inherently controlled by save/restore.
So, add a finalize method for the XPS device's image enumerator
(xps_image_enum_finalize()) which takes over cleaning up the memory it allocates
and also deals with cleaning up references from the device to the enumerator
and from the enumerator to the device. |
static int fsmClose(FD_t *wfdp)
{
int rc = 0;
if (wfdp && *wfdp) {
int myerrno = errno;
static int oneshot = 0;
static int flush_io = 0;
int fdno = Fileno(*wfdp);
if (!oneshot) {
flush_io = (rpmExpandNumeric("%{?_flush_io}") > 0);
oneshot = 1;
}
if (flush_io) {
fsync(fdno);
}
if (Fclose(*wfdp))
rc = RPMERR_CLOSE_FAILED;
if (_fsm_debug) {
rpmlog(RPMLOG_DEBUG, " %8s ([%d]) %s\n", __func__,
fdno, (rc < 0 ? strerror(errno) : ""));
}
*wfdp = NULL;
errno = myerrno;
}
return rc;
} | 0 | []
| rpm | 96ec957e281220f8e137a2d5eb23b83a6377d556 | 152,599,772,521,723,570,000,000,000,000,000,000,000 | 28 | Validate intermediate symlinks during installation, CVE-2021-35939
Whenever directory changes during unpacking, walk the entire tree from
starting from / and validate any symlinks crossed, fail the install
on invalid links.
This is the first of step of many towards securing our file operations
against local tamperers and besides plugging that one CVE, paves the way
for the next step by adding the necessary directory fd tracking.
This also bumps the rpm OS requirements to a whole new level by requiring
the *at() family of calls from POSIX-1.2008.
This necessarily does a whole lot of huffing and puffing we previously
did not do. It should be possible to cache secure (ie root-owned)
directory structures to avoid validating everything a million times
but for now, just keeping things simple. |
InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
{
FunctionCallInfoData fcinfo;
Datum result;
bool pushed;
if (str == NULL && flinfo->fn_strict)
return (Datum) 0; /* just return null result */
pushed = SPI_push_conditional();
InitFunctionCallInfoData(fcinfo, flinfo, 3, InvalidOid, NULL, NULL);
fcinfo.arg[0] = CStringGetDatum(str);
fcinfo.arg[1] = ObjectIdGetDatum(typioparam);
fcinfo.arg[2] = Int32GetDatum(typmod);
fcinfo.argnull[0] = (str == NULL);
fcinfo.argnull[1] = false;
fcinfo.argnull[2] = false;
result = FunctionCallInvoke(&fcinfo);
/* Should get null result if and only if str is NULL */
if (str == NULL)
{
if (!fcinfo.isnull)
elog(ERROR, "input function %u returned non-NULL",
fcinfo.flinfo->fn_oid);
}
else
{
if (fcinfo.isnull)
elog(ERROR, "input function %u returned NULL",
fcinfo.flinfo->fn_oid);
}
SPI_pop_conditional(pushed);
return result;
} | 0 | [
"CWE-264"
]
| postgres | 537cbd35c893e67a63c59bc636c3e888bd228bc7 | 45,087,154,518,845,360,000,000,000,000,000,000,000 | 40 | Prevent privilege escalation in explicit calls to PL validators.
The primary role of PL validators is to be called implicitly during
CREATE FUNCTION, but they are also normal functions that a user can call
explicitly. Add a permissions check to each validator to ensure that a
user cannot use explicit validator calls to achieve things he could not
otherwise achieve. Back-patch to 8.4 (all supported versions).
Non-core procedural language extensions ought to make the same two-line
change to their own validators.
Andres Freund, reviewed by Tom Lane and Noah Misch.
Security: CVE-2014-0061 |
static void naludmx_check_pid(GF_Filter *filter, GF_NALUDmxCtx *ctx, Bool force_au_flush)
{
u32 w, h, ew, eh;
u8 *dsi, *dsi_enh;
u32 dsi_size, dsi_enh_size;
u32 crc_cfg, crc_cfg_enh;
GF_Fraction sar;
Bool has_hevc_base = GF_TRUE;
Bool has_colr_info = GF_FALSE;
if (ctx->analyze) {
if (ctx->opid && !ctx->ps_modified) return;
} else {
if (!ctx->ps_modified) return;
if (ctx->opid && (!gf_list_count(ctx->sps) || !gf_list_count(ctx->pps)))
return;
}
ctx->ps_modified = GF_FALSE;
dsi = dsi_enh = NULL;
if (ctx->notime) {
ctx->cur_fps = ctx->fps;
if (!ctx->cur_fps.num || !ctx->cur_fps.den) {
ctx->cur_fps.num = 25000;
ctx->cur_fps.den = 1000;
}
}
if (ctx->codecid==GF_CODECID_HEVC) {
naludmx_create_hevc_decoder_config(ctx, &dsi, &dsi_size, &dsi_enh, &dsi_enh_size, &w, &h, &ew, &eh, &sar, &has_hevc_base);
} else if (ctx->codecid==GF_CODECID_VVC) {
naludmx_create_vvc_decoder_config(ctx, &dsi, &dsi_size, &dsi_enh, &dsi_enh_size, &w, &h, &ew, &eh, &sar, &has_hevc_base);
} else {
naludmx_create_avc_decoder_config(ctx, &dsi, &dsi_size, &dsi_enh, &dsi_enh_size, &w, &h, &ew, &eh, &sar);
}
crc_cfg = crc_cfg_enh = 0;
if (dsi) crc_cfg = gf_crc_32(dsi, dsi_size);
if (dsi_enh) crc_cfg_enh = gf_crc_32(dsi_enh, dsi_enh_size);
if (!ctx->analyze && (!w || !h)) {
if (dsi) gf_free(dsi);
if (dsi_enh) gf_free(dsi_enh);
return;
}
if (!ctx->opid) {
ctx->opid = gf_filter_pid_new(filter);
naludmx_check_dur(filter, ctx);
ctx->first_slice_in_au = GF_TRUE;
}
if ((ctx->crc_cfg == crc_cfg) && (ctx->crc_cfg_enh == crc_cfg_enh)
&& (ctx->width==w) && (ctx->height==h)
&& (ctx->sar.num * sar.den == ctx->sar.den * sar.num)
) {
if (dsi) gf_free(dsi);
if (dsi_enh) gf_free(dsi_enh);
return;
}
if (force_au_flush) {
naludmx_end_access_unit(ctx);
}
naludmx_enqueue_or_dispatch(ctx, NULL, GF_TRUE);
if (!ctx->analyze && (gf_list_count(ctx->pck_queue)>1)) {
GF_LOG(dsi_enh ? GF_LOG_DEBUG : GF_LOG_ERROR, GF_LOG_MEDIA, ("[%s] xPS changed but could not flush frames before signaling state change %s\n", ctx->log_name, dsi_enh ? "- likely scalable xPS update" : "!"));
}
//copy properties at init or reconfig
gf_filter_pid_copy_properties(ctx->opid, ctx->ipid);
//don't change codec type if reframing an ES (for HLS SAES)
if (!ctx->timescale)
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, & PROP_UINT(GF_STREAM_VISUAL));
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_UNFRAMED, NULL);
if (!gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_ID))
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(1));
ctx->width = w;
ctx->height = h;
ctx->sar = sar;
ctx->crc_cfg = crc_cfg;
ctx->crc_cfg_enh = crc_cfg_enh;
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, & PROP_UINT( ctx->width));
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, & PROP_UINT( ctx->height));
if (ew && eh) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH_MAX, & PROP_UINT( ew ));
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT_MAX, & PROP_UINT( eh ));
}
if (ctx->sar.den)
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_SAR, & PROP_FRAC(ctx->sar));
else
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_SAR, NULL);
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_FPS, & PROP_FRAC(ctx->cur_fps));
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, & PROP_UINT(ctx->timescale ? ctx->timescale : ctx->cur_fps.num));
if (ctx->explicit || !has_hevc_base) {
u32 enh_cid = GF_CODECID_SVC;
if (ctx->codecid==GF_CODECID_HEVC) enh_cid = GF_CODECID_LHVC;
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, & PROP_UINT(enh_cid));
if (dsi) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, &PROP_DATA_NO_COPY(dsi, dsi_size) );
} else {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, & PROP_UINT(ctx->codecid));
if (dsi) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG, &PROP_DATA_NO_COPY(dsi, dsi_size) );
if (dsi_enh) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DECODER_CONFIG_ENHANCEMENT, &PROP_DATA_NO_COPY(dsi_enh, dsi_enh_size) );
}
if (ctx->bitrate) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_BITRATE, & PROP_UINT(ctx->bitrate));
}
if ((ctx->codecid==GF_CODECID_HEVC) && gf_list_count(ctx->vps) ) {
GF_Err e = naludmx_set_hevc_oinf(ctx, NULL);
if (e) {
GF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, ("[%s] Failed to create OINF chunk\n", ctx->log_name));
}
naludmx_set_hevc_linf(ctx);
}
if (ctx->duration.num)
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DURATION, & PROP_FRAC64(ctx->duration));
if (ctx->is_file /* && ctx->index*/) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_PLAYBACK_MODE, & PROP_UINT(GF_PLAYBACK_MODE_FASTFORWARD) );
}
//set interlaced or remove interlaced property
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_INTERLACED, ctx->interlaced ? & PROP_UINT(GF_TRUE) : NULL);
if (ctx->codecid==GF_CODECID_HEVC) {
HEVC_SPS *sps = &ctx->hevc_state->sps[ctx->hevc_state->sps_active_idx];
if (sps->colour_description_present_flag) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_PRIMARIES, & PROP_UINT(sps->colour_primaries) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_TRANSFER, & PROP_UINT(sps->transfer_characteristic) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_MX, & PROP_UINT(sps->matrix_coeffs) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_RANGE, & PROP_BOOL(sps->video_full_range_flag) );
has_colr_info = GF_TRUE;
}
} else if (ctx->codecid==GF_CODECID_VVC) {
} else {
/*use the last active SPS*/
if (ctx->avc_state->sps[ctx->avc_state->sps_active_idx].vui_parameters_present_flag
&& ctx->avc_state->sps[ctx->avc_state->sps_active_idx].vui.colour_description_present_flag) {
AVC_VUI *vui = &ctx->avc_state->sps[ctx->avc_state->sps_active_idx].vui;
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_PRIMARIES, & PROP_UINT(vui->colour_primaries) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_TRANSFER, & PROP_UINT(vui->transfer_characteristics) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_MX, & PROP_UINT(vui->matrix_coefficients) );
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_RANGE, & PROP_BOOL(vui->video_full_range_flag) );
has_colr_info = GF_TRUE;
}
}
if (!has_colr_info) {
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_PRIMARIES, NULL);
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_TRANSFER, NULL);
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_MX, NULL);
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_COLR_RANGE, NULL);
}
naludmx_update_clli_mdcv(ctx, GF_TRUE);
naludmx_set_dolby_vision(ctx);
} | 0 | [
"CWE-476"
]
| gpac | b43f9d1a4b4e33d08edaef6d313e6ce4bdf554d3 | 91,972,554,383,257,180,000,000,000,000,000,000,000 | 168 | fixed #2223 |
virtual void help(stringstream& ss) const {
ss << "internal" << endl;
} | 0 | [
"CWE-613"
]
| mongo | db19e7ce84cfd702a4ba9983ee2ea5019f470f82 | 250,764,740,031,166,750,000,000,000,000,000,000,000 | 3 | SERVER-38984 Validate unique User ID on UserCache hit
(cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7) |
iobuf_get_fname_nonnull (iobuf_t a)
{
const char *fname;
fname = iobuf_get_fname (a);
return fname? fname : "[?]";
} | 0 | [
"CWE-20"
]
| gnupg | 2183683bd633818dd031b090b5530951de76f392 | 284,398,744,766,530,650,000,000,000,000,000,000,000 | 7 | Use inline functions to convert buffer data to scalars.
* common/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.
--
Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to
avoid all sign extension on shift problems. Hanno Böck found a case
with an invalid read due to this problem. To fix that once and for
all almost all uses of "<< 24" and "<< 8" are changed by this patch to
use an inline function from host2net.h.
Signed-off-by: Werner Koch <[email protected]> |
bool fix_fields(THD *thd, Item **it)
{
if ((*ref)->fix_fields_if_needed_for_scalar(thd, ref))
return TRUE;
return Item_ref::fix_fields(thd, it);
} | 0 | [
"CWE-617"
]
| server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | 163,713,285,686,854,180,000,000,000,000,000,000,000 | 6 | MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...
When doing condition pushdown from HAVING into WHERE,
Item_equal::create_pushable_equalities() calls
item->set_extraction_flag(IMMUTABLE_FL) for constant items.
Then, Item::cleanup_excluding_immutables_processor() checks for this flag
to see if it should call item->cleanup() or leave the item as-is.
The failure happens when a constant item has a non-constant one inside it,
like:
(tbl.col=0 AND impossible_cond)
item->walk(cleanup_excluding_immutables_processor) works in a bottom-up
way so it
1. will call Item_func_eq(tbl.col=0)->cleanup()
2. will not call Item_cond_and->cleanup (as the AND is constant)
This creates an item tree where a fixed Item has an un-fixed Item inside
it which eventually causes an assertion failure.
Fixed by introducing this rule: instead of just calling
item->set_extraction_flag(IMMUTABLE_FL);
we call Item::walk() to set the flag for all sub-items of the item. |
web_view_is_loading (GoaWebView *self)
{
GoaWebViewPrivate *priv = self->priv;
WebKitLoadStatus status;
status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (priv->web_view));
if ((priv->status == WEBKIT_LOAD_FINISHED || priv->status == WEBKIT_LOAD_FAILED)
&& status != WEBKIT_LOAD_PROVISIONAL)
return FALSE;
priv->status = status;
return status != WEBKIT_LOAD_FINISHED && status != WEBKIT_LOAD_FAILED;
} | 0 | [
"CWE-310"
]
| gnome-online-accounts | edde7c63326242a60a075341d3fea0be0bc4d80e | 93,438,354,899,586,440,000,000,000,000,000,000,000 | 14 | Guard against invalid SSL certificates
None of the branded providers (eg., Google, Facebook and Windows Live)
should ever have an invalid certificate. So set "ssl-strict" on the
SoupSession object being used by GoaWebView.
Providers like ownCloud and Exchange might have to deal with
certificates that are not up to the mark. eg., self-signed
certificates. For those, show a warning when the account is being
created, and only proceed if the user decides to ignore it. In any
case, save the status of the certificate that was used to create the
account. So an account created with a valid certificate will never
work with an invalid one, and one created with an invalid certificate
will not throw any further warnings.
Fixes: CVE-2013-0240 |
static bool io_wq_worker_cancel(struct io_worker *worker, void *data)
{
struct io_wq_work *work = data;
unsigned long flags;
bool ret = false;
if (worker->cur_work != work)
return false;
spin_lock_irqsave(&worker->lock, flags);
if (worker->cur_work == work) {
send_sig(SIGINT, worker->task, 1);
ret = true;
}
spin_unlock_irqrestore(&worker->lock, flags);
return ret;
} | 0 | []
| linux | 181e448d8709e517c9c7b523fcd209f24eb38ca7 | 251,936,578,775,120,340,000,000,000,000,000,000,000 | 18 | io_uring: async workers should inherit the user creds
If we don't inherit the original task creds, then we can confuse users
like fuse that pass creds in the request header. See link below on
identical aio issue.
Link: https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u
Signed-off-by: Jens Axboe <[email protected]> |
int SSL_add_client_CA(SSL *ssl, X509 *x)
{
return add_ca_name(&ssl->client_ca_names, x);
} | 0 | [
"CWE-835"
]
| openssl | 758754966791c537ea95241438454aa86f91f256 | 79,657,817,027,276,240,000,000,000,000,000,000,000 | 4 | Fix invalid handling of verify errors in libssl
In the event that X509_verify() returned an internal error result then
libssl would mishandle this and set rwstate to SSL_RETRY_VERIFY. This
subsequently causes SSL_get_error() to return SSL_ERROR_WANT_RETRY_VERIFY.
That return code is supposed to only ever be returned if an application
is using an app verify callback to complete replace the use of
X509_verify(). Applications may not be written to expect that return code
and could therefore crash (or misbehave in some other way) as a result.
CVE-2021-4044
Reviewed-by: Tomas Mraz <[email protected]> |
bool walk(Item_processor processor, bool walk_subquery, void *args)
{
return (item->walk(processor, walk_subquery, args)) ||
(this->*processor)(args);
} | 0 | [
"CWE-617"
]
| server | 2e7891080667c59ac80f788eef4d59d447595772 | 325,207,680,219,276,470,000,000,000,000,000,000,000 | 5 | MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view
This bug could manifest itself after pushing a where condition over a
mergeable derived table / view / CTE DT into a grouping view / derived
table / CTE V whose item list contained set functions with constant
arguments such as MIN(2), SUM(1) etc. In such cases the field references
used in the condition pushed into the view V that correspond set functions
are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation
of the virtual method const_item() for the class Item_direct_view_ref the
wrapped set functions with constant arguments could be erroneously taken
for constant items. This could lead to a wrong result set returned by the
main select query in 10.2. In 10.4 where a possibility of pushing condition
from HAVING into WHERE had been added this could cause a crash.
Approved by Sergey Petrunya <[email protected]> |
static void lo_write_buf(fuse_req_t req, fuse_ino_t ino,
struct fuse_bufvec *in_buf, off_t off,
struct fuse_file_info *fi)
{
(void)ino;
ssize_t res;
struct fuse_bufvec out_buf = FUSE_BUFVEC_INIT(fuse_buf_size(in_buf));
bool cap_fsetid_dropped = false;
out_buf.buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK;
out_buf.buf[0].fd = lo_fi_fd(req, fi);
out_buf.buf[0].pos = off;
fuse_log(FUSE_LOG_DEBUG,
"lo_write_buf(ino=%" PRIu64 ", size=%zd, off=%lu kill_priv=%d)\n",
ino, out_buf.buf[0].size, (unsigned long)off, fi->kill_priv);
/*
* If kill_priv is set, drop CAP_FSETID which should lead to kernel
* clearing setuid/setgid on file. Note, for WRITE, we need to do
* this even if killpriv_v2 is not enabled. fuse direct write path
* relies on this.
*/
if (fi->kill_priv) {
res = drop_effective_cap("FSETID", &cap_fsetid_dropped);
if (res != 0) {
fuse_reply_err(req, res);
return;
}
}
res = fuse_buf_copy(&out_buf, in_buf);
if (res < 0) {
fuse_reply_err(req, -res);
} else {
fuse_reply_write(req, (size_t)res);
}
if (cap_fsetid_dropped) {
res = gain_effective_cap("FSETID");
if (res) {
fuse_log(FUSE_LOG_ERR, "Failed to gain CAP_FSETID\n");
}
}
} | 1 | [
"CWE-281"
]
| qemu | e586edcb410543768ef009eaa22a2d9dd4a53846 | 72,249,315,256,821,850,000,000,000,000,000,000,000 | 45 | virtiofs: drop remapped security.capability xattr as needed
On Linux, the 'security.capability' xattr holds a set of
capabilities that can change when an executable is run, giving
a limited form of privilege escalation to those programs that
the writer of the file deemed worthy.
Any write causes the 'security.capability' xattr to be dropped,
stopping anyone from gaining privilege by modifying a blessed
file.
Fuse relies on the daemon to do this dropping, and in turn the
daemon relies on the host kernel to drop the xattr for it. However,
with the addition of -o xattrmap, the xattr that the guest
stores its capabilities in is now not the same as the one that
the host kernel automatically clears.
Where the mapping changes 'security.capability', explicitly clear
the remapped name to preserve the same behaviour.
This bug is assigned CVE-2021-20263.
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Vivek Goyal <[email protected]> |
Item_hex_constant(THD *thd, const char *str, size_t str_length):
Item_literal(thd)
{
hex_string_init(thd, str, str_length);
} | 0 | [
"CWE-617"
]
| server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | 304,322,383,995,017,900,000,000,000,000,000,000,000 | 5 | MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...
When doing condition pushdown from HAVING into WHERE,
Item_equal::create_pushable_equalities() calls
item->set_extraction_flag(IMMUTABLE_FL) for constant items.
Then, Item::cleanup_excluding_immutables_processor() checks for this flag
to see if it should call item->cleanup() or leave the item as-is.
The failure happens when a constant item has a non-constant one inside it,
like:
(tbl.col=0 AND impossible_cond)
item->walk(cleanup_excluding_immutables_processor) works in a bottom-up
way so it
1. will call Item_func_eq(tbl.col=0)->cleanup()
2. will not call Item_cond_and->cleanup (as the AND is constant)
This creates an item tree where a fixed Item has an un-fixed Item inside
it which eventually causes an assertion failure.
Fixed by introducing this rule: instead of just calling
item->set_extraction_flag(IMMUTABLE_FL);
we call Item::walk() to set the flag for all sub-items of the item. |
asmlinkage long sys_setuid(uid_t uid)
{
int old_euid = current->euid;
int old_ruid, old_suid, new_suid;
int retval;
retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
if (retval)
return retval;
old_ruid = current->uid;
old_suid = current->suid;
new_suid = old_suid;
if (capable(CAP_SETUID)) {
if (uid != old_ruid && set_user(uid, old_euid != uid) < 0)
return -EAGAIN;
new_suid = uid;
} else if ((uid != current->uid) && (uid != new_suid))
return -EPERM;
if (old_euid != uid) {
current->mm->dumpable = suid_dumpable;
smp_wmb();
}
current->fsuid = current->euid = uid;
current->suid = new_suid;
key_fsuid_changed(current);
proc_id_connector(current, PROC_EVENT_UID);
return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
} | 0 | [
"CWE-20"
]
| linux-2.6 | 9926e4c74300c4b31dee007298c6475d33369df0 | 61,150,799,898,324,865,000,000,000,000,000,000,000 | 33 | CPU time limit patch / setrlimit(RLIMIT_CPU, 0) cheat fix
As discovered here today, the change in Kernel 2.6.17 intended to inhibit
users from setting RLIMIT_CPU to 0 (as that is equivalent to unlimited) by
"cheating" and setting it to 1 in such a case, does not make a difference,
as the check is done in the wrong place (too late), and only applies to the
profiling code.
On all systems I checked running kernels above 2.6.17, no matter what the
hard and soft CPU time limits were before, a user could escape them by
issuing in the shell (sh/bash/zsh) "ulimit -t 0", and then the user's
process was not ever killed.
Attached is a trivial patch to fix that. Simply moving the check to a
slightly earlier location (specifically, before the line that actually
assigns the limit - *old_rlim = new_rlim), does the trick.
Do note that at least the zsh (but not ash, dash, or bash) shell has the
problem of "caching" the limits set by the ulimit command, so when running
zsh the fix will not immediately be evident - after entering "ulimit -t 0",
"ulimit -a" will show "-t: cpu time (seconds) 0", even though the actual
limit as returned by getrlimit(...) will be 1. It can be verified by
opening a subshell (which will not have the values of the parent shell in
cache) and checking in it, or just by running a CPU intensive command like
"echo '65536^1048576' | bc" and verifying that it dumps core after one
second.
Regardless of whether that is a misfeature in the shell, perhaps it would
be better to return -EINVAL from setrlimit in such a case instead of
cheating and setting to 1, as that does not really reflect the actual state
of the process anymore. I do not however know what the ground for that
decision was in the original 2.6.17 change, and whether there would be any
"backward" compatibility issues, so I preferred not to touch that right
now.
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *in_tm)
{
time_t t;
int type = -1;
if (in_tm)
t = *in_tm;
else
time(&t);
t += adj;
if (s)
type = s->type;
if (type == V_ASN1_UTCTIME)
return ASN1_UTCTIME_set(s, t);
if (type == V_ASN1_GENERALIZEDTIME)
return ASN1_GENERALIZEDTIME_set(s, t);
return ASN1_TIME_set(s, t);
} | 0 | [
"CWE-119"
]
| openssl | fa57f74a3941db6b2efb2f43c6add914ec83db20 | 26,626,776,771,757,210,000,000,000,000,000,000,000 | 19 | Fix length checks in X509_cmp_time to avoid out-of-bounds reads.
Also tighten X509_cmp_time to reject more than three fractional
seconds in the time; and to reject trailing garbage after the offset.
CVE-2015-1789
Reviewed-by: Viktor Dukhovni <[email protected]>
Reviewed-by: Richard Levitte <[email protected]> |
WriteWrap* StreamBase::CreateWriteWrap(
Local<Object> object) {
auto* wrap = new SimpleWriteWrap<AsyncWrap>(this, object);
wrap->MakeWeak();
return wrap;
} | 0 | [
"CWE-416"
]
| node | 4f8772f9b731118628256189b73cd202149bbd97 | 3,855,344,452,144,118,400,000,000,000,000,000,000 | 6 | src: retain pointers to WriteWrap/ShutdownWrap
Avoids potential use-after-free when wrap req's are synchronously
destroyed.
CVE-ID: CVE-2020-8265
Fixes: https://github.com/nodejs-private/node-private/issues/227
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=988103
PR-URL: https://github.com/nodejs-private/node-private/pull/23
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rich Trott <[email protected]> |
int sqlite3Fts3DeferToken(
Fts3Cursor *pCsr, /* Fts3 table cursor */
Fts3PhraseToken *pToken, /* Token to defer */
int iCol /* Column that token must appear in (or -1) */
){
Fts3DeferredToken *pDeferred;
pDeferred = sqlite3_malloc(sizeof(*pDeferred));
if( !pDeferred ){
return SQLITE_NOMEM;
}
memset(pDeferred, 0, sizeof(*pDeferred));
pDeferred->pToken = pToken;
pDeferred->pNext = pCsr->pDeferred;
pDeferred->iCol = iCol;
pCsr->pDeferred = pDeferred;
assert( pToken->pDeferred==0 );
pToken->pDeferred = pDeferred;
return SQLITE_OK;
} | 0 | [
"CWE-787"
]
| sqlite | c72f2fb7feff582444b8ffdc6c900c69847ce8a9 | 80,294,718,818,791,780,000,000,000,000,000,000,000 | 21 | More improvements to shadow table corruption detection in FTS3.
FossilOrigin-Name: 51525f9c3235967bc00a090e84c70a6400698c897aa4742e817121c725b8c99d |
SWFShape_setMorphFlag(SWFShape shape)
{
shape->isMorph = TRUE;
} | 0 | [
"CWE-20",
"CWE-476"
]
| libming | 6e76e8c71cb51c8ba0aa9737a636b9ac3029887f | 259,509,697,100,899,730,000,000,000,000,000,000,000 | 4 | SWFShape_setLeftFillStyle: prevent fill overflow |
get_subnet(uint32_t *addr, unsigned int where)
{
int off;
off = where / 32;
where %= 32;
return (addr[off] >> (32 - NBITS - where)) & ((1UL << NBITS) - 1);
} | 0 | []
| chrony | 8f72155b438494e6d8e9e75920c36fd88d90f5b2 | 152,849,906,963,156,850,000,000,000,000,000,000,000 | 9 | Multiply clientlog node table size when reallocating |
static bool dce120_hw_sequencer_create(struct dc *dc)
{
/* All registers used by dce11.2 match those in dce11 in offset and
* structure
*/
dce120_hw_sequencer_construct(dc);
/*TODO Move to separate file and Override what is needed */
return true;
} | 0 | [
"CWE-400",
"CWE-401"
]
| linux | 104c307147ad379617472dd91a5bcb368d72bd6d | 320,120,840,448,682,980,000,000,000,000,000,000,000 | 11 | drm/amd/display: prevent memory leak
In dcn*_create_resource_pool the allocated memory should be released if
construct pool fails.
Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Alex Deucher <[email protected]> |
md_is_autolink_uri(MD_CTX* ctx, OFF beg, OFF max_end, OFF* p_end)
{
OFF off = beg+1;
MD_ASSERT(CH(beg) == _T('<'));
/* Check for scheme. */
if(off >= max_end || !ISASCII(off))
return FALSE;
off++;
while(1) {
if(off >= max_end)
return FALSE;
if(off - beg > 32)
return FALSE;
if(CH(off) == _T(':') && off - beg >= 3)
break;
if(!ISALNUM(off) && CH(off) != _T('+') && CH(off) != _T('-') && CH(off) != _T('.'))
return FALSE;
off++;
}
/* Check the path after the scheme. */
while(off < max_end && CH(off) != _T('>')) {
if(ISWHITESPACE(off) || ISCNTRL(off) || CH(off) == _T('<'))
return FALSE;
off++;
}
if(off >= max_end)
return FALSE;
MD_ASSERT(CH(off) == _T('>'));
*p_end = off+1;
return TRUE;
} | 0 | [
"CWE-125",
"CWE-908"
]
| md4c | 4fc808d8fe8d8904f8525bb4231d854f45e23a19 | 84,318,583,818,791,070,000,000,000,000,000,000,000 | 36 | md_analyze_line: Avoid reading 1 byte beyond the input size.
Fixes #155. |
static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
{
struct page *page = c->page;
int tail = 1;
if (page->freelist)
stat(c, DEACTIVATE_REMOTE_FREES);
/*
* Merge cpu freelist into slab freelist. Typically we get here
* because both freelists are empty. So this is unlikely
* to occur.
*/
while (unlikely(c->freelist)) {
void **object;
tail = 0; /* Hot objects. Put the slab first */
/* Retrieve object from cpu_freelist */
object = c->freelist;
c->freelist = c->freelist[c->offset];
/* And put onto the regular freelist */
object[c->offset] = page->freelist;
page->freelist = object;
page->inuse--;
}
c->page = NULL;
unfreeze_slab(s, page, tail);
} | 0 | [
"CWE-189"
]
| linux | f8bd2258e2d520dff28c855658bd24bdafb5102d | 236,095,190,432,316,760,000,000,000,000,000,000,000 | 29 | 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 <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: john stultz <[email protected]>
Cc: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
TEST(IndexBoundsBuilderTest,
TranslateNotEqualToNullShouldBuildExactBoundsIfIndexIsNotMultiKeyOnRelevantPath) {
BSONObj indexPattern = BSON("a" << 1 << "b" << 1);
auto testIndex = buildSimpleIndexEntry(indexPattern);
testIndex.multikeyPaths = {{}, {0}}; // "a" is not multi-key, but "b" is.
for (BSONObj obj : kNeNullQueries) {
// It's necessary to call optimize since the $not will have a singleton $and child, which
// IndexBoundsBuilder::translate cannot handle.
auto expr = MatchExpression::optimize(parseMatchExpression(obj));
OrderedIntervalList oil;
IndexBoundsBuilder::BoundsTightness tightness;
IndexBoundsBuilder::translate(
expr.get(), indexPattern.firstElement(), testIndex, &oil, &tightness);
// Bounds should be [MinKey, undefined), (null, MaxKey].
ASSERT_EQUALS(oil.name, "a");
ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
assertBoundsRepresentNotEqualsNull(oil);
}
} | 0 | [
"CWE-754"
]
| mongo | f8f55e1825ee5c7bdb3208fc7c5b54321d172732 | 33,232,528,462,187,194,000,000,000,000,000,000,000 | 22 | SERVER-44377 generate correct plan for indexed inequalities to null |
int AVI_audio_mp3rate(avi_t *AVI)
{
return AVI->track[AVI->aptr].mp3rate;
} | 0 | [
"CWE-835"
]
| gpac | 7f060bbb72966cae80d6fee338d0b07fa3fc06e1 | 17,723,799,957,689,220,000,000,000,000,000,000,000 | 4 | fixed #2159 |
bool Item_cache_row::setup(THD *thd, Item *item)
{
example= item;
null_value= true;
if (!values && allocate(thd, item->cols()))
return 1;
for (uint i= 0; i < item_count; i++)
{
Item *el= item->element_index(i);
Item_cache *tmp;
if (!(tmp= values[i]= el->get_cache(thd)))
return 1;
tmp->setup(thd, el);
}
return 0;
} | 0 | [
"CWE-416"
]
| server | c02ebf3510850ba78a106be9974c94c3b97d8585 | 41,382,034,586,423,537,000,000,000,000,000,000,000 | 17 | MDEV-24176 Preparations
1. moved fix_vcol_exprs() call to open_table()
mysql_alter_table() doesn't do lock_tables() so it cannot win from
fix_vcol_exprs() from there. Tests affected: main.default_session
2. Vanilla cleanups and comments. |
static void qemu_sgl_init_external(VirtIOSCSIReq *req, struct iovec *sg,
hwaddr *addr, int num)
{
QEMUSGList *qsgl = &req->qsgl;
qemu_sglist_init(qsgl, DEVICE(req->dev), num, &address_space_memory);
while (num--) {
qemu_sglist_add(qsgl, *(addr++), (sg++)->iov_len);
}
} | 0 | [
"CWE-119"
]
| qemu | 3c3ce981423e0d6c18af82ee62f1850c2cda5976 | 222,137,799,586,179,200,000,000,000,000,000,000,000 | 10 | virtio-scsi: fix buffer overrun on invalid state load
CVE-2013-4542
hw/scsi/scsi-bus.c invokes load_request.
virtio_scsi_load_request does:
qemu_get_buffer(f, (unsigned char *)&req->elem, sizeof(req->elem));
this probably can make elem invalid, for example,
make in_num or out_num huge, then:
virtio_scsi_parse_req(s, vs->cmd_vqs[n], req);
will do:
if (req->elem.out_num > 1) {
qemu_sgl_init_external(req, &req->elem.out_sg[1],
&req->elem.out_addr[1],
req->elem.out_num - 1);
} else {
qemu_sgl_init_external(req, &req->elem.in_sg[1],
&req->elem.in_addr[1],
req->elem.in_num - 1);
}
and this will access out of array bounds.
Note: this adds security checks within assert calls since
SCSIBusInfo's load_request cannot fail.
For now simply disable builds with NDEBUG - there seems
to be little value in supporting these.
Cc: Andreas Färber <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Juan Quintela <[email protected]> |
bool is_null() { return 1; } | 0 | []
| mysql-server | f7316aa0c9a3909fc7498e7b95d5d3af044a7e21 | 28,391,381,462,202,540,000,000,000,000,000,000,000 | 1 | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST,
COL), NAME_CONST('NAME', NULL))
Backport of Bug#19143243 fix.
NAME_CONST item can return NULL_ITEM type in case of incorrect arguments.
NULL_ITEM has special processing in Item_func_in function.
In Item_func_in::fix_length_and_dec an array of possible comparators is
created. Since NAME_CONST function has NULL_ITEM type, corresponding
array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE.
ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(),
so the NULL_ITEM is attempted compared with an empty comparator.
The fix is to disable the caching of Item_name_const item. |
option_expand(int opt_idx, char_u *val)
{
/* if option doesn't need expansion nothing to do */
if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
return NULL;
/* If val is longer than MAXPATHL no meaningful expansion can be done,
* expand_env() would truncate the string. */
if (val != NULL && STRLEN(val) > MAXPATHL)
return NULL;
if (val == NULL)
val = *(char_u **)options[opt_idx].var;
/*
* Expanding this with NameBuff, expand_env() must not be passed IObuff.
* Escape spaces when expanding 'tags', they are used to separate file
* names.
* For 'spellsuggest' expand after "file:".
*/
expand_env_esc(val, NameBuff, MAXPATHL,
(char_u **)options[opt_idx].var == &p_tags, FALSE,
#ifdef FEAT_SPELL
(char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
#endif
NULL);
if (STRCMP(NameBuff, val) == 0) /* they are the same */
return NULL;
return NameBuff;
} | 0 | [
"CWE-20"
]
| vim | d0b5138ba4bccff8a744c99836041ef6322ed39a | 239,075,317,013,150,500,000,000,000,000,000,000,000 | 31 | patch 8.0.0056
Problem: When setting 'filetype' there is no check for a valid name.
Solution: Only allow valid characters in 'filetype', 'syntax' and 'keymap'. |
static __cold void io_tctx_exit_cb(struct callback_head *cb)
{
struct io_uring_task *tctx = current->io_uring;
struct io_tctx_exit *work;
work = container_of(cb, struct io_tctx_exit, task_work);
/*
* When @in_idle, we're in cancellation and it's racy to remove the
* node. It'll be removed by the end of cancellation, just ignore it.
*/
if (!atomic_read(&tctx->in_idle))
io_uring_del_tctx_node((unsigned long)work->ctx);
complete(&work->completion); | 0 | [
"CWE-416"
]
| linux | e677edbcabee849bfdd43f1602bccbecf736a646 | 281,388,734,100,520,450,000,000,000,000,000,000,000 | 14 | io_uring: fix race between timeout flush and removal
io_flush_timeouts() assumes the timeout isn't in progress of triggering
or being removed/canceled, so it unconditionally removes it from the
timeout list and attempts to cancel it.
Leave it on the list and let the normal timeout cancelation take care
of it.
Cc: [email protected] # 5.5+
Signed-off-by: Jens Axboe <[email protected]> |
static int invalid_frame_pointer(void __user *fp, int fplen)
{
if (((unsigned long) fp) & 7)
return 1;
return 0;
} | 0 | []
| linux-2.6 | ee18d64c1f632043a02e6f5ba5e045bb26a5465f | 174,090,790,266,021,930,000,000,000,000,000,000,000 | 6 | KEYS: Add a keyctl to install a process's session keyring on its parent [try #6]
Add a keyctl to install a process's session keyring onto its parent. This
replaces the parent's session keyring. Because the COW credential code does
not permit one process to change another process's credentials directly, the
change is deferred until userspace next starts executing again. Normally this
will be after a wait*() syscall.
To support this, three new security hooks have been provided:
cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in
the blank security creds and key_session_to_parent() - which asks the LSM if
the process may replace its parent's session keyring.
The replacement may only happen if the process has the same ownership details
as its parent, and the process has LINK permission on the session keyring, and
the session keyring is owned by the process, and the LSM permits it.
Note that this requires alteration to each architecture's notify_resume path.
This has been done for all arches barring blackfin, m68k* and xtensa, all of
which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the
replacement to be performed at the point the parent process resumes userspace
execution.
This allows the userspace AFS pioctl emulation to fully emulate newpag() and
the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to
alter the parent process's PAG membership. However, since kAFS doesn't use
PAGs per se, but rather dumps the keys into the session keyring, the session
keyring of the parent must be replaced if, for example, VIOCSETTOK is passed
the newpag flag.
This can be tested with the following program:
#include <stdio.h>
#include <stdlib.h>
#include <keyutils.h>
#define KEYCTL_SESSION_TO_PARENT 18
#define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0)
int main(int argc, char **argv)
{
key_serial_t keyring, key;
long ret;
keyring = keyctl_join_session_keyring(argv[1]);
OSERROR(keyring, "keyctl_join_session_keyring");
key = add_key("user", "a", "b", 1, keyring);
OSERROR(key, "add_key");
ret = keyctl(KEYCTL_SESSION_TO_PARENT);
OSERROR(ret, "KEYCTL_SESSION_TO_PARENT");
return 0;
}
Compiled and linked with -lkeyutils, you should see something like:
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
355907932 --alswrv 4043 -1 \_ keyring: _uid.4043
[dhowells@andromeda ~]$ /tmp/newpag
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
1055658746 --alswrv 4043 4043 \_ user: a
[dhowells@andromeda ~]$ /tmp/newpag hello
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: hello
340417692 --alswrv 4043 4043 \_ user: a
Where the test program creates a new session keyring, sticks a user key named
'a' into it and then installs it on its parent.
Signed-off-by: David Howells <[email protected]>
Signed-off-by: James Morris <[email protected]> |
void would_dump(struct linux_binprm *bprm, struct file *file)
{
struct inode *inode = file_inode(file);
if (inode_permission(inode, MAY_READ) < 0) {
struct user_namespace *old, *user_ns;
bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
/* Ensure mm->user_ns contains the executable */
user_ns = old = bprm->mm->user_ns;
while ((user_ns != &init_user_ns) &&
!privileged_wrt_inode_uidgid(user_ns, inode))
user_ns = user_ns->parent;
if (old != user_ns) {
bprm->mm->user_ns = get_user_ns(user_ns);
put_user_ns(old);
}
}
} | 0 | []
| linux | 98da7d08850fb8bdeb395d6368ed15753304aa0c | 53,885,353,480,737,400,000,000,000,000,000,000,000 | 19 | fs/exec.c: account for argv/envp pointers
When limiting the argv/envp strings during exec to 1/4 of the stack limit,
the storage of the pointers to the strings was not included. This means
that an exec with huge numbers of tiny strings could eat 1/4 of the stack
limit in strings and then additional space would be later used by the
pointers to the strings.
For example, on 32-bit with a 8MB stack rlimit, an exec with 1677721
single-byte strings would consume less than 2MB of stack, the max (8MB /
4) amount allowed, but the pointers to the strings would consume the
remaining additional stack space (1677721 * 4 == 6710884).
The result (1677721 + 6710884 == 8388605) would exhaust stack space
entirely. Controlling this stack exhaustion could result in
pathological behavior in setuid binaries (CVE-2017-1000365).
[[email protected]: additional commenting from Kees]
Fixes: b6a2fea39318 ("mm: variable length argument support")
Link: http://lkml.kernel.org/r/20170622001720.GA32173@beast
Signed-off-by: Kees Cook <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Qualys Security Advisory <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static int __kvm_read_guest_page(struct kvm_memory_slot *slot, gfn_t gfn,
void *data, int offset, int len)
{
int r;
unsigned long addr;
addr = gfn_to_hva_memslot_prot(slot, gfn, NULL);
if (kvm_is_error_hva(addr))
return -EFAULT;
r = __copy_from_user(data, (void __user *)addr + offset, len);
if (r)
return -EFAULT;
return 0; | 0 | [
"CWE-459"
]
| linux | 683412ccf61294d727ead4a73d97397396e69a6b | 78,979,491,194,514,220,000,000,000,000,000,000,000 | 14 | KVM: SEV: add cache flush to solve SEV cache incoherency issues
Flush the CPU caches when memory is reclaimed from an SEV guest (where
reclaim also includes it being unmapped from KVM's memslots). Due to lack
of coherency for SEV encrypted memory, failure to flush results in silent
data corruption if userspace is malicious/broken and doesn't ensure SEV
guest memory is properly pinned and unpinned.
Cache coherency is not enforced across the VM boundary in SEV (AMD APM
vol.2 Section 15.34.7). Confidential cachelines, generated by confidential
VM guests have to be explicitly flushed on the host side. If a memory page
containing dirty confidential cachelines was released by VM and reallocated
to another user, the cachelines may corrupt the new user at a later time.
KVM takes a shortcut by assuming all confidential memory remain pinned
until the end of VM lifetime. Therefore, KVM does not flush cache at
mmu_notifier invalidation events. Because of this incorrect assumption and
the lack of cache flushing, malicous userspace can crash the host kernel:
creating a malicious VM and continuously allocates/releases unpinned
confidential memory pages when the VM is running.
Add cache flush operations to mmu_notifier operations to ensure that any
physical memory leaving the guest VM get flushed. In particular, hook
mmu_notifier_invalidate_range_start and mmu_notifier_release events and
flush cache accordingly. The hook after releasing the mmu lock to avoid
contention with other vCPUs.
Cc: [email protected]
Suggested-by: Sean Christpherson <[email protected]>
Reported-by: Mingwei Zhang <[email protected]>
Signed-off-by: Mingwei Zhang <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]> |
int user_preparse(struct key_preparsed_payload *prep)
{
struct user_key_payload *upayload;
size_t datalen = prep->datalen;
if (datalen <= 0 || datalen > 32767 || !prep->data)
return -EINVAL;
upayload = kmalloc(sizeof(*upayload) + datalen, GFP_KERNEL);
if (!upayload)
return -ENOMEM;
/* attach the data */
prep->quotalen = datalen;
prep->payload[0] = upayload;
upayload->datalen = datalen;
memcpy(upayload->data, prep->data, datalen);
return 0;
} | 0 | [
"CWE-476"
]
| linux | c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81 | 240,560,757,815,979,430,000,000,000,000,000,000,000 | 19 | KEYS: Remove key_type::match in favour of overriding default by match_preparse
A previous patch added a ->match_preparse() method to the key type. This is
allowed to override the function called by the iteration algorithm.
Therefore, we can just set a default that simply checks for an exact match of
the key description with the original criterion data and allow match_preparse
to override it as needed.
The key_type::match op is then redundant and can be removed, as can the
user_match() function.
Signed-off-by: David Howells <[email protected]>
Acked-by: Vivek Goyal <[email protected]> |
void Hybrid_type_traits_decimal::div(Hybrid_type *val, ulonglong u) const
{
int2my_decimal(E_DEC_FATAL_ERROR, u, TRUE, &val->dec_buf[2]);
/* XXX: what is '4' for scale? */
my_decimal_div(E_DEC_FATAL_ERROR,
&val->dec_buf[val->used_dec_buf_no ^ 1],
&val->dec_buf[val->used_dec_buf_no],
&val->dec_buf[2], 4);
val->used_dec_buf_no^= 1;
} | 0 | []
| server | b000e169562697aa072600695d4f0c0412f94f4f | 284,200,424,628,649,170,000,000,000,000,000,000,000 | 10 | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL))
based on:
commit f7316aa0c9a
Author: Ajo Robert <[email protected]>
Date: Thu Aug 24 17:03:21 2017 +0530
Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST,
COL), NAME_CONST('NAME', NULL))
Backport of Bug#19143243 fix.
NAME_CONST item can return NULL_ITEM type in case of incorrect arguments.
NULL_ITEM has special processing in Item_func_in function.
In Item_func_in::fix_length_and_dec an array of possible comparators is
created. Since NAME_CONST function has NULL_ITEM type, corresponding
array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE.
ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(),
so the NULL_ITEM is attempted compared with an empty comparator.
The fix is to disable the caching of Item_name_const item. |
ins_compl_infercase_gettext(
char_u *str,
int char_len,
int compl_char_len,
int min_len,
char_u **tofree)
{
int *wca; // Wide character array.
char_u *p;
int i, c;
int has_lower = FALSE;
int was_letter = FALSE;
garray_T gap;
IObuff[0] = NUL;
// Allocate wide character array for the completion and fill it.
wca = ALLOC_MULT(int, char_len);
if (wca == NULL)
return IObuff;
p = str;
for (i = 0; i < char_len; ++i)
if (has_mbyte)
wca[i] = mb_ptr2char_adv(&p);
else
wca[i] = *(p++);
// Rule 1: Were any chars converted to lower?
p = compl_orig_text;
for (i = 0; i < min_len; ++i)
{
if (has_mbyte)
c = mb_ptr2char_adv(&p);
else
c = *(p++);
if (MB_ISLOWER(c))
{
has_lower = TRUE;
if (MB_ISUPPER(wca[i]))
{
// Rule 1 is satisfied.
for (i = compl_char_len; i < char_len; ++i)
wca[i] = MB_TOLOWER(wca[i]);
break;
}
}
}
// Rule 2: No lower case, 2nd consecutive letter converted to
// upper case.
if (!has_lower)
{
p = compl_orig_text;
for (i = 0; i < min_len; ++i)
{
if (has_mbyte)
c = mb_ptr2char_adv(&p);
else
c = *(p++);
if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i]))
{
// Rule 2 is satisfied.
for (i = compl_char_len; i < char_len; ++i)
wca[i] = MB_TOUPPER(wca[i]);
break;
}
was_letter = MB_ISLOWER(c) || MB_ISUPPER(c);
}
}
// Copy the original case of the part we typed.
p = compl_orig_text;
for (i = 0; i < min_len; ++i)
{
if (has_mbyte)
c = mb_ptr2char_adv(&p);
else
c = *(p++);
if (MB_ISLOWER(c))
wca[i] = MB_TOLOWER(wca[i]);
else if (MB_ISUPPER(c))
wca[i] = MB_TOUPPER(wca[i]);
}
// Generate encoding specific output from wide character array.
p = IObuff;
i = 0;
ga_init2(&gap, 1, 500);
while (i < char_len)
{
if (gap.ga_data != NULL)
{
if (ga_grow(&gap, 10) == FAIL)
{
ga_clear(&gap);
return (char_u *)"[failed]";
}
p = (char_u *)gap.ga_data + gap.ga_len;
if (has_mbyte)
gap.ga_len += (*mb_char2bytes)(wca[i++], p);
else
{
*p = wca[i++];
++gap.ga_len;
}
}
else if ((p - IObuff) + 6 >= IOSIZE)
{
// Multi-byte characters can occupy up to five bytes more than
// ASCII characters, and we also need one byte for NUL, so when
// getting to six bytes from the edge of IObuff switch to using a
// growarray. Add the character in the next round.
if (ga_grow(&gap, IOSIZE) == FAIL)
return (char_u *)"[failed]";
*p = NUL;
STRCPY(gap.ga_data, IObuff);
gap.ga_len = (int)STRLEN(IObuff);
}
else if (has_mbyte)
p += (*mb_char2bytes)(wca[i++], p);
else
*(p++) = wca[i++];
}
vim_free(wca);
if (gap.ga_data != NULL)
{
*tofree = gap.ga_data;
return gap.ga_data;
}
*p = NUL;
return IObuff;
} | 0 | [
"CWE-122"
]
| vim | b9e717367c395490149495cf375911b5d9de889e | 175,622,032,503,930,540,000,000,000,000,000,000,000 | 135 | patch 9.0.0060: accessing uninitialized memory when completing long line
Problem: Accessing uninitialized memory when completing long line.
Solution: Terminate string with NUL. |
static int ext4_unfreeze(struct super_block *sb)
{
if (sb->s_flags & MS_RDONLY)
return 0;
lock_super(sb);
/* Reset the needs_recovery flag before the fs is unlocked. */
EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
ext4_commit_super(sb, 1);
unlock_super(sb);
jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
return 0;
} | 0 | [
"CWE-703"
]
| linux | 744692dc059845b2a3022119871846e74d4f6e11 | 268,921,006,176,669,820,000,000,000,000,000,000,000 | 13 | ext4: use ext4_get_block_write in buffer write
Allocate uninitialized extent before ext4 buffer write and
convert the extent to initialized after io completes.
The purpose is to make sure an extent can only be marked
initialized after it has been written with new data so
we can safely drop the i_mutex lock in ext4 DIO read without
exposing stale data. This helps to improve multi-thread DIO
read performance on high-speed disks.
Skip the nobh and data=journal mount cases to make things simple for now.
Signed-off-by: Jiaying Zhang <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]> |
static bool io_queue_worker_create(struct io_worker *worker,
struct io_wqe_acct *acct,
task_work_func_t func)
{
struct io_wqe *wqe = worker->wqe;
struct io_wq *wq = wqe->wq;
/* raced with exit, just ignore create call */
if (test_bit(IO_WQ_BIT_EXIT, &wq->state))
goto fail;
if (!io_worker_get(worker))
goto fail;
/*
* create_state manages ownership of create_work/index. We should
* only need one entry per worker, as the worker going to sleep
* will trigger the condition, and waking will clear it once it
* runs the task_work.
*/
if (test_bit(0, &worker->create_state) ||
test_and_set_bit_lock(0, &worker->create_state))
goto fail_release;
init_task_work(&worker->create_work, func);
worker->create_index = acct->index;
if (!task_work_add(wq->task, &worker->create_work, TWA_SIGNAL))
return true;
clear_bit_unlock(0, &worker->create_state);
fail_release:
io_worker_release(worker);
fail:
atomic_dec(&acct->nr_running);
io_worker_ref_put(wq);
return false;
} | 0 | [
"CWE-200"
]
| linux | 713b9825a4c47897f66ad69409581e7734a8728e | 227,926,398,376,707,100,000,000,000,000,000,000,000 | 34 | io-wq: fix cancellation on create-worker failure
WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151 req_ref_put_and_test
fs/io_uring.c:1151 [inline]
WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151 req_ref_put_and_test
fs/io_uring.c:1146 [inline]
WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151
io_req_complete_post+0xf5b/0x1190 fs/io_uring.c:1794
Modules linked in:
Call Trace:
tctx_task_work+0x1e5/0x570 fs/io_uring.c:2158
task_work_run+0xe0/0x1a0 kernel/task_work.c:164
tracehook_notify_signal include/linux/tracehook.h:212 [inline]
handle_signal_work kernel/entry/common.c:146 [inline]
exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
exit_to_user_mode_prepare+0x232/0x2a0 kernel/entry/common.c:209
__syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x44/0xae
When io_wqe_enqueue() -> io_wqe_create_worker() fails, we can't just
call io_run_cancel() to clean up the request, it's already enqueued via
io_wqe_insert_work() and will be executed either by some other worker
during cancellation (e.g. in io_wq_put_and_exit()).
Reported-by: Hao Sun <[email protected]>
Fixes: 3146cba99aa28 ("io-wq: make worker creation resilient against signals")
Signed-off-by: Pavel Begunkov <[email protected]>
Link: https://lore.kernel.org/r/93b9de0fcf657affab0acfd675d4abcd273ee863.1631092071.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <[email protected]> |
static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
{
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
unsigned int segno;
mutex_lock(&dirty_i->seglist_lock);
for_each_set_bit(segno, dirty_i->dirty_segmap[PRE], MAIN_SEGS(sbi))
__set_test_and_free(sbi, segno);
mutex_unlock(&dirty_i->seglist_lock);
} | 0 | [
"CWE-20"
]
| linux | 638164a2718f337ea224b747cf5977ef143166a4 | 230,495,832,366,551,630,000,000,000,000,000,000,000 | 10 | f2fs: fix potential panic during fstrim
As Ju Hyung Park reported:
"When 'fstrim' is called for manual trim, a BUG() can be triggered
randomly with this patch.
I'm seeing this issue on both x86 Desktop and arm64 Android phone.
On x86 Desktop, this was caused during Ubuntu boot-up. I have a
cronjob installed which calls 'fstrim -v /' during boot. On arm64
Android, this was caused during GC looping with 1ms gc_min_sleep_time
& gc_max_sleep_time."
Root cause of this issue is that f2fs_wait_discard_bios can only be
used by f2fs_put_super, because during put_super there must be no
other referrers, so it can ignore discard entry's reference count
when removing the entry, otherwise in other caller we will hit bug_on
in __remove_discard_cmd as there may be other issuer added reference
count in discard entry.
Thread A Thread B
- issue_discard_thread
- f2fs_ioc_fitrim
- f2fs_trim_fs
- f2fs_wait_discard_bios
- __issue_discard_cmd
- __submit_discard_cmd
- __wait_discard_cmd
- dc->ref++
- __wait_one_discard_bio
- __wait_discard_cmd
- __remove_discard_cmd
- f2fs_bug_on(sbi, dc->ref)
Fixes: 969d1b180d987c2be02de890d0fff0f66a0e80de
Reported-by: Ju Hyung Park <[email protected]>
Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]> |
CiffComponent::~CiffComponent()
{
if (isAllocated_) delete[] pData_;
} | 0 | [
"CWE-400"
]
| exiv2 | b3d077dcaefb6747fff8204490f33eba5a144edb | 288,332,443,780,387,200,000,000,000,000,000,000,000 | 4 | Fix #460 by adding more checks in CiffDirectory::readDirectory |
xfs_attr3_leaf_lookup_int(
struct xfs_buf *bp,
struct xfs_da_args *args)
{
struct xfs_attr_leafblock *leaf;
struct xfs_attr3_icleaf_hdr ichdr;
struct xfs_attr_leaf_entry *entry;
struct xfs_attr_leaf_entry *entries;
struct xfs_attr_leaf_name_local *name_loc;
struct xfs_attr_leaf_name_remote *name_rmt;
xfs_dahash_t hashval;
int probe;
int span;
trace_xfs_attr_leaf_lookup(args);
leaf = bp->b_addr;
xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
entries = xfs_attr3_leaf_entryp(leaf);
ASSERT(ichdr.count < XFS_LBSIZE(args->dp->i_mount) / 8);
/*
* Binary search. (note: small blocks will skip this loop)
*/
hashval = args->hashval;
probe = span = ichdr.count / 2;
for (entry = &entries[probe]; span > 4; entry = &entries[probe]) {
span /= 2;
if (be32_to_cpu(entry->hashval) < hashval)
probe += span;
else if (be32_to_cpu(entry->hashval) > hashval)
probe -= span;
else
break;
}
ASSERT(probe >= 0 && (!ichdr.count || probe < ichdr.count));
ASSERT(span <= 4 || be32_to_cpu(entry->hashval) == hashval);
/*
* Since we may have duplicate hashval's, find the first matching
* hashval in the leaf.
*/
while (probe > 0 && be32_to_cpu(entry->hashval) >= hashval) {
entry--;
probe--;
}
while (probe < ichdr.count &&
be32_to_cpu(entry->hashval) < hashval) {
entry++;
probe++;
}
if (probe == ichdr.count || be32_to_cpu(entry->hashval) != hashval) {
args->index = probe;
return XFS_ERROR(ENOATTR);
}
/*
* Duplicate keys may be present, so search all of them for a match.
*/
for (; probe < ichdr.count && (be32_to_cpu(entry->hashval) == hashval);
entry++, probe++) {
/*
* GROT: Add code to remove incomplete entries.
*/
/*
* If we are looking for INCOMPLETE entries, show only those.
* If we are looking for complete entries, show only those.
*/
if ((args->flags & XFS_ATTR_INCOMPLETE) !=
(entry->flags & XFS_ATTR_INCOMPLETE)) {
continue;
}
if (entry->flags & XFS_ATTR_LOCAL) {
name_loc = xfs_attr3_leaf_name_local(leaf, probe);
if (name_loc->namelen != args->namelen)
continue;
if (memcmp(args->name, name_loc->nameval,
args->namelen) != 0)
continue;
if (!xfs_attr_namesp_match(args->flags, entry->flags))
continue;
args->index = probe;
return XFS_ERROR(EEXIST);
} else {
name_rmt = xfs_attr3_leaf_name_remote(leaf, probe);
if (name_rmt->namelen != args->namelen)
continue;
if (memcmp(args->name, name_rmt->name,
args->namelen) != 0)
continue;
if (!xfs_attr_namesp_match(args->flags, entry->flags))
continue;
args->index = probe;
args->valuelen = be32_to_cpu(name_rmt->valuelen);
args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
args->rmtblkcnt = xfs_attr3_rmt_blocks(
args->dp->i_mount,
args->valuelen);
return XFS_ERROR(EEXIST);
}
}
args->index = probe;
return XFS_ERROR(ENOATTR);
} | 1 | [
"CWE-241",
"CWE-19"
]
| linux | 8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59 | 175,218,177,065,330,150,000,000,000,000,000,000,000 | 104 | xfs: remote attribute overwrite causes transaction overrun
Commit e461fcb ("xfs: remote attribute lookups require the value
length") passes the remote attribute length in the xfs_da_args
structure on lookup so that CRC calculations and validity checking
can be performed correctly by related code. This, unfortunately has
the side effect of changing the args->valuelen parameter in cases
where it shouldn't.
That is, when we replace a remote attribute, the incoming
replacement stores the value and length in args->value and
args->valuelen, but then the lookup which finds the existing remote
attribute overwrites args->valuelen with the length of the remote
attribute being replaced. Hence when we go to create the new
attribute, we create it of the size of the existing remote
attribute, not the size it is supposed to be. When the new attribute
is much smaller than the old attribute, this results in a
transaction overrun and an ASSERT() failure on a debug kernel:
XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, file: fs/xfs/xfs_trans.c, line: 331
Fix this by keeping the remote attribute value length separate to
the attribute value length in the xfs_da_args structure. The enables
us to pass the length of the remote attribute to be removed without
overwriting the new attribute's length.
Also, ensure that when we save remote block contexts for a later
rename we zero the original state variables so that we don't confuse
the state of the attribute to be removes with the state of the new
attribute that we just added. [Spotted by Brain Foster.]
Signed-off-by: Dave Chinner <[email protected]>
Reviewed-by: Brian Foster <[email protected]>
Signed-off-by: Dave Chinner <[email protected]> |
static int hns_nic_common_poll(struct napi_struct *napi, int budget)
{
int clean_complete = 0;
struct hns_nic_ring_data *ring_data =
container_of(napi, struct hns_nic_ring_data, napi);
struct hnae_ring *ring = ring_data->ring;
try_again:
clean_complete += ring_data->poll_one(
ring_data, budget - clean_complete,
ring_data->ex_process);
if (clean_complete < budget) {
if (ring_data->fini_process(ring_data)) {
napi_complete(napi);
ring->q->handle->dev->ops->toggle_ring_irq(ring, 0);
} else {
goto try_again;
}
}
return clean_complete;
} | 0 | [
"CWE-416"
]
| linux | 27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2 | 164,718,208,652,416,420,000,000,000,000,000,000,000 | 23 | net: hns: Fix a skb used after free bug
skb maybe freed in hns_nic_net_xmit_hw() and return NETDEV_TX_OK,
which cause hns_nic_net_xmit to use a freed skb.
BUG: KASAN: use-after-free in hns_nic_net_xmit_hw+0x62c/0x940...
[17659.112635] alloc_debug_processing+0x18c/0x1a0
[17659.117208] __slab_alloc+0x52c/0x560
[17659.120909] kmem_cache_alloc_node+0xac/0x2c0
[17659.125309] __alloc_skb+0x6c/0x260
[17659.128837] tcp_send_ack+0x8c/0x280
[17659.132449] __tcp_ack_snd_check+0x9c/0xf0
[17659.136587] tcp_rcv_established+0x5a4/0xa70
[17659.140899] tcp_v4_do_rcv+0x27c/0x620
[17659.144687] tcp_prequeue_process+0x108/0x170
[17659.149085] tcp_recvmsg+0x940/0x1020
[17659.152787] inet_recvmsg+0x124/0x180
[17659.156488] sock_recvmsg+0x64/0x80
[17659.160012] SyS_recvfrom+0xd8/0x180
[17659.163626] __sys_trace_return+0x0/0x4
[17659.167506] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=23 cpu=1 pid=13
[17659.174000] free_debug_processing+0x1d4/0x2c0
[17659.178486] __slab_free+0x240/0x390
[17659.182100] kmem_cache_free+0x24c/0x270
[17659.186062] kfree_skbmem+0xa0/0xb0
[17659.189587] __kfree_skb+0x28/0x40
[17659.193025] napi_gro_receive+0x168/0x1c0
[17659.197074] hns_nic_rx_up_pro+0x58/0x90
[17659.201038] hns_nic_rx_poll_one+0x518/0xbc0
[17659.205352] hns_nic_common_poll+0x94/0x140
[17659.209576] net_rx_action+0x458/0x5e0
[17659.213363] __do_softirq+0x1b8/0x480
[17659.217062] run_ksoftirqd+0x64/0x80
[17659.220679] smpboot_thread_fn+0x224/0x310
[17659.224821] kthread+0x150/0x170
[17659.228084] ret_from_fork+0x10/0x40
BUG: KASAN: use-after-free in hns_nic_net_xmit+0x8c/0xc0...
[17751.080490] __slab_alloc+0x52c/0x560
[17751.084188] kmem_cache_alloc+0x244/0x280
[17751.088238] __build_skb+0x40/0x150
[17751.091764] build_skb+0x28/0x100
[17751.095115] __alloc_rx_skb+0x94/0x150
[17751.098900] __napi_alloc_skb+0x34/0x90
[17751.102776] hns_nic_rx_poll_one+0x180/0xbc0
[17751.107097] hns_nic_common_poll+0x94/0x140
[17751.111333] net_rx_action+0x458/0x5e0
[17751.115123] __do_softirq+0x1b8/0x480
[17751.118823] run_ksoftirqd+0x64/0x80
[17751.122437] smpboot_thread_fn+0x224/0x310
[17751.126575] kthread+0x150/0x170
[17751.129838] ret_from_fork+0x10/0x40
[17751.133454] INFO: Freed in kfree_skbmem+0xa0/0xb0 age=19 cpu=7 pid=43
[17751.139951] free_debug_processing+0x1d4/0x2c0
[17751.144436] __slab_free+0x240/0x390
[17751.148051] kmem_cache_free+0x24c/0x270
[17751.152014] kfree_skbmem+0xa0/0xb0
[17751.155543] __kfree_skb+0x28/0x40
[17751.159022] napi_gro_receive+0x168/0x1c0
[17751.163074] hns_nic_rx_up_pro+0x58/0x90
[17751.167041] hns_nic_rx_poll_one+0x518/0xbc0
[17751.171358] hns_nic_common_poll+0x94/0x140
[17751.175585] net_rx_action+0x458/0x5e0
[17751.179373] __do_softirq+0x1b8/0x480
[17751.183076] run_ksoftirqd+0x64/0x80
[17751.186691] smpboot_thread_fn+0x224/0x310
[17751.190826] kthread+0x150/0x170
[17751.194093] ret_from_fork+0x10/0x40
Fixes: 13ac695e7ea1 ("net:hns: Add support of Hip06 SoC to the Hislicon Network Subsystem")
Signed-off-by: Yunsheng Lin <[email protected]>
Signed-off-by: lipeng <[email protected]>
Reported-by: Jun He <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
free_tabpage(tabpage_T *tp)
{
int idx;
# ifdef FEAT_DIFF
diff_clear(tp);
# endif
# ifdef FEAT_PROP_POPUP
while (tp->tp_first_popupwin != NULL)
popup_close_tabpage(tp, tp->tp_first_popupwin->w_id, TRUE);
#endif
for (idx = 0; idx < SNAP_COUNT; ++idx)
clear_snapshot(tp, idx);
#ifdef FEAT_EVAL
vars_clear(&tp->tp_vars->dv_hashtab); // free all t: variables
hash_init(&tp->tp_vars->dv_hashtab);
unref_var_dict(tp->tp_vars);
#endif
if (tp == lastused_tabpage)
lastused_tabpage = NULL;
vim_free(tp->tp_localdir);
vim_free(tp->tp_prevdir);
#ifdef FEAT_PYTHON
python_tabpage_free(tp);
#endif
#ifdef FEAT_PYTHON3
python3_tabpage_free(tp);
#endif
vim_free(tp);
} | 0 | [
"CWE-476"
]
| vim | 0f6e28f686dbb59ab3b562408ab9b2234797b9b1 | 55,265,959,313,760,770,000,000,000,000,000,000,000 | 35 | patch 8.2.4428: crash when switching tabpage while in the cmdline window
Problem: Crash when switching tabpage while in the cmdline window.
Solution: Disallow switching tabpage when in the cmdline window. |
ensure_current_configuration_is_saved (void)
{
GnomeRRScreen *rr_screen;
GnomeRRConfig *rr_config;
/* Normally, gnome_rr_config_save() creates a backup file based on the
* old monitors.xml. However, if *that* file didn't exist, there is
* nothing from which to create a backup. So, here we'll save the
* current/unchanged configuration and then let our caller call
* gnome_rr_config_save() again with the new/changed configuration, so
* that there *will* be a backup file in the end.
*/
rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, NULL); /* NULL-GError */
if (!rr_screen)
return;
rr_config = gnome_rr_config_new_current (rr_screen);
gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
gnome_rr_config_free (rr_config);
gnome_rr_screen_destroy (rr_screen);
} | 0 | []
| gnome-settings-daemon | be513b3c7d80d0b7013d79ce46d7eeca929705cc | 261,594,414,360,344,600,000,000,000,000,000,000,000 | 23 | Implement autoconfiguration of the outputs
This is similar in spirit to 'xrandr --auto', but we disfavor selecting clone modes.
Instead, we lay out the outputs left-to-right.
Signed-off-by: Federico Mena Quintero <[email protected]> |
url_uses_proxy (struct url * u)
{
bool ret;
char *proxy;
if (!u)
return false;
proxy = getproxy (u);
ret = proxy != NULL;
xfree (proxy);
return ret;
} | 0 | [
"CWE-119"
]
| wget | ba6b44f6745b14dce414761a8e4b35d31b176bba | 84,233,886,096,781,500,000,000,000,000,000,000,000 | 12 | Fix heap overflow in HTTP protocol handling (CVE-2017-13090)
* src/retr.c (fd_read_body): Stop processing on negative chunk size
Reported-by: Antti Levomäki, Christian Jalio, Joonas Pihlaja from Forcepoint
Reported-by: Juhani Eronen from Finnish National Cyber Security Centre |
static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
int vector)
{
struct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic);
struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
int auto_eoi_old, auto_eoi_new;
if (vector < HV_SYNIC_FIRST_VALID_VECTOR)
return;
if (synic_has_vector_connected(synic, vector))
__set_bit(vector, synic->vec_bitmap);
else
__clear_bit(vector, synic->vec_bitmap);
auto_eoi_old = bitmap_weight(synic->auto_eoi_bitmap, 256);
if (synic_has_vector_auto_eoi(synic, vector))
__set_bit(vector, synic->auto_eoi_bitmap);
else
__clear_bit(vector, synic->auto_eoi_bitmap);
auto_eoi_new = bitmap_weight(synic->auto_eoi_bitmap, 256);
if (!!auto_eoi_old == !!auto_eoi_new)
return;
if (!enable_apicv)
return;
down_write(&vcpu->kvm->arch.apicv_update_lock);
if (auto_eoi_new)
hv->synic_auto_eoi_used++;
else
hv->synic_auto_eoi_used--;
__kvm_request_apicv_update(vcpu->kvm,
!hv->synic_auto_eoi_used,
APICV_INHIBIT_REASON_HYPERV);
up_write(&vcpu->kvm->arch.apicv_update_lock);
} | 0 | [
"CWE-476"
]
| linux | 7ec37d1cbe17d8189d9562178d8b29167fe1c31a | 103,695,408,906,888,870,000,000,000,000,000,000,000 | 43 | KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for
irqchip_in_kernel() so normally SynIC irqs should never be set. It is,
however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs
causing erroneous behavior.
The immediate issue being fixed is that kvm_irq_delivery_to_apic()
(kvm_irq_delivery_to_apic_fast()) crashes when called with
'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'.
Signed-off-by: Vitaly Kuznetsov <[email protected]>
Message-Id: <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]> |
Subsets and Splits