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
|
---|---|---|---|---|---|---|---|
gdImagePtr gdImageCreateFromXbm(FILE * fd)
{
char fline[MAX_XBM_LINE_SIZE];
char iname[MAX_XBM_LINE_SIZE];
char *type;
int value;
unsigned int width = 0, height = 0;
int fail = 0;
int max_bit = 0;
gdImagePtr im;
int bytes = 0, i;
int bit, x = 0, y = 0;
int ch;
char h[8];
unsigned int b;
rewind(fd);
while (fgets(fline, MAX_XBM_LINE_SIZE, fd)) {
fline[MAX_XBM_LINE_SIZE-1] = '\0';
if (strlen(fline) == MAX_XBM_LINE_SIZE-1) {
return 0;
}
if (sscanf(fline, "#define %s %d", iname, &value) == 2) {
if (!(type = strrchr(iname, '_'))) {
type = iname;
} else {
type++;
}
if (!strcmp("width", type)) {
width = (unsigned int) value;
}
if (!strcmp("height", type)) {
height = (unsigned int) value;
}
} else {
if ( sscanf(fline, "static unsigned char %s = {", iname) == 1
|| sscanf(fline, "static char %s = {", iname) == 1)
{
max_bit = 128;
} else if (sscanf(fline, "static unsigned short %s = {", iname) == 1
|| sscanf(fline, "static short %s = {", iname) == 1)
{
max_bit = 32768;
}
if (max_bit) {
bytes = (width + 7) / 8 * height;
if (!bytes) {
return 0;
}
if (!(type = strrchr(iname, '_'))) {
type = iname;
} else {
type++;
}
if (!strcmp("bits[]", type)) {
break;
}
}
}
}
if (!bytes || !max_bit) {
return 0;
}
if(!(im = gdImageCreate(width, height))) {
return 0;
}
gdImageColorAllocate(im, 255, 255, 255);
gdImageColorAllocate(im, 0, 0, 0);
h[2] = '\0';
h[4] = '\0';
for (i = 0; i < bytes; i++) {
while (1) {
if ((ch=getc(fd)) == EOF) {
fail = 1;
break;
}
if (ch == 'x') {
break;
}
}
if (fail) {
break;
}
/* Get hex value */
if ((ch=getc(fd)) == EOF) {
break;
}
h[0] = ch;
if ((ch=getc(fd)) == EOF) {
break;
}
h[1] = ch;
if (max_bit == 32768) {
if ((ch=getc(fd)) == EOF) {
break;
}
h[2] = ch;
if ((ch=getc(fd)) == EOF) {
break;
}
h[3] = ch;
}
if (sscanf(h, "%x", &b) != 1) {
php_gd_error("invalid XBM");
gdImageDestroy(im);
return 0;
}
for (bit = 1; bit <= max_bit; bit = bit << 1) {
gdImageSetPixel(im, x++, y, (b & bit) ? 1 : 0);
if (x == im->sx) {
x = 0;
y++;
if (y == im->sy) {
return im;
}
break;
}
}
}
php_gd_error("EOF before image was complete");
gdImageDestroy(im);
return 0;
} | 0 | [
"CWE-908"
]
| php-src | ed6dee9a198c904ad5e03113e58a2d2c200f5184 | 1,858,295,820,955,081,200,000,000,000,000,000,000 | 127 | Fix #77973: Uninitialized read in gdImageCreateFromXbm
We have to ensure that `sscanf()` does indeed read a hex value here,
and bail out otherwise. |
void Item_trigger_field::set_required_privilege(bool rw)
{
/*
Require SELECT and UPDATE privilege if this field will be read and
set, and only UPDATE privilege for setting the field.
*/
want_privilege= (rw ? SELECT_ACL | UPDATE_ACL : UPDATE_ACL);
} | 0 | []
| server | b000e169562697aa072600695d4f0c0412f94f4f | 340,251,475,144,884,850,000,000,000,000,000,000,000 | 8 | 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. |
static void skb_gro_reset_offset(struct sk_buff *skb)
{
const struct skb_shared_info *pinfo = skb_shinfo(skb);
const skb_frag_t *frag0 = &pinfo->frags[0];
NAPI_GRO_CB(skb)->data_offset = 0;
NAPI_GRO_CB(skb)->frag0 = NULL;
NAPI_GRO_CB(skb)->frag0_len = 0;
if (skb_mac_header(skb) == skb_tail_pointer(skb) &&
pinfo->nr_frags &&
!PageHighMem(skb_frag_page(frag0))) {
NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
NAPI_GRO_CB(skb)->frag0_len = skb_frag_size(frag0);
} | 0 | [
"CWE-400",
"CWE-703"
]
| linux | fac8e0f579695a3ecbc4d3cac369139d7f819971 | 174,953,552,329,153,880,000,000,000,000,000,000,000 | 16 | tunnels: Don't apply GRO to multiple layers of encapsulation.
When drivers express support for TSO of encapsulated packets, they
only mean that they can do it for one layer of encapsulation.
Supporting additional levels would mean updating, at a minimum,
more IP length fields and they are unaware of this.
No encapsulation device expresses support for handling offloaded
encapsulated packets, so we won't generate these types of frames
in the transmit path. However, GRO doesn't have a check for
multiple levels of encapsulation and will attempt to build them.
UDP tunnel GRO actually does prevent this situation but it only
handles multiple UDP tunnels stacked on top of each other. This
generalizes that solution to prevent any kind of tunnel stacking
that would cause problems.
Fixes: bf5a755f ("net-gre-gro: Add GRE support to the GRO stack")
Signed-off-by: Jesse Gross <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
void WebContents::DevToolsOpened() {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
DCHECK(inspectable_web_contents_);
DCHECK(inspectable_web_contents_->GetDevToolsWebContents());
auto handle = FromOrCreate(
isolate, inspectable_web_contents_->GetDevToolsWebContents());
devtools_web_contents_.Reset(isolate, handle.ToV8());
// Set inspected tabID.
base::Value tab_id(ID());
inspectable_web_contents_->CallClientFunction("DevToolsAPI.setInspectedTabId",
&tab_id, nullptr, nullptr);
// Inherit owner window in devtools when it doesn't have one.
auto* devtools = inspectable_web_contents_->GetDevToolsWebContents();
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
if (owner_window() && !has_window)
handle->SetOwnerWindow(devtools, owner_window());
Emit("devtools-opened");
} | 0 | []
| electron | e9fa834757f41c0b9fe44a4dffe3d7d437f52d34 | 324,206,048,126,515,920,000,000,000,000,000,000,000 | 23 | fix: ensure ElectronBrowser mojo service is only bound to appropriate render frames (#33344)
* fix: ensure ElectronBrowser mojo service is only bound to authorized render frames
Notes: no-notes
* refactor: extract electron API IPC to its own mojo interface
* fix: just check main frame not primary main frame
Co-authored-by: Samuel Attard <[email protected]>
Co-authored-by: Samuel Attard <[email protected]> |
pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
{
InitializeCriticalSection(mutex);
return 0;
} | 1 | [
"CWE-703",
"CWE-125"
]
| portable | 17c88164016df821df2dff4b2b1291291ec4f28a | 51,339,741,359,860,370,000,000,000,000,000,000,000 | 5 | Make pthread_mutex static initialisation work on Windows.
This takes the dynamic initialisation code added to CRYPTO_lock() in e5081719
and applies it to the Window's pthread_mutex implementation. This allows for
PTHREAD_MUTEX_INITIALIZER to be used on Windows.
bcook has agreed to place this code in the public domain (as per the rest of
the code in pthread.h). |
uint32_t mobi_buffer_get_varlen_dec(MOBIBuffer *buf, size_t *len) {
return _buffer_get_varlen(buf, len, -1);
} | 0 | [
"CWE-787"
]
| libmobi | ab5bf0e37e540eac682a14e628853b918626e72b | 146,365,576,616,527,260,000,000,000,000,000,000,000 | 3 | fix oob write bug inside libmobi |
void* Type_ColorantOrderType_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
{
return _cmsDupMem(self ->ContextID, Ptr, cmsMAXCHANNELS * sizeof(cmsUInt8Number));
cmsUNUSED_PARAMETER(n);
} | 0 | []
| Little-CMS | 41d222df1bc6188131a8f46c32eab0a4d4cdf1b6 | 221,562,501,923,429,500,000,000,000,000,000,000,000 | 6 | Memory squeezing fix: lcms2 cmsPipeline construction
When creating a new pipeline, lcms would often try to allocate a stage
and pass it to cmsPipelineInsertStage without checking whether the
allocation succeeded. cmsPipelineInsertStage would then assert (or crash)
if it had not.
The fix here is to change cmsPipelineInsertStage to check and return
an error value. All calling code is then checked to test this return
value and cope. |
static int r_cmd_is_object_descriptor (const char *name, ut32 name_len) {
int found_L = false, found_Semi = false;
ut32 idx = 0, L_pos = 0, Semi_pos = 0;
const char *p_name = name;
for (idx = 0, L_pos = 0; idx < name_len; idx++,p_name++) {
if (*p_name == 'L') {
found_L = true;
L_pos = idx;
break;
}
}
for (idx = 0, Semi_pos = 0; idx < name_len; idx++,p_name++) {
if (*p_name == ';') {
found_Semi = true;
Semi_pos = idx;
break;
}
}
return true ? found_L == found_Semi && found_L == true && L_pos < Semi_pos : false;
} | 0 | [
"CWE-703",
"CWE-193"
]
| radare2 | ced0223c7a1b3b5344af315715cd28fe7c0d9ebc | 199,081,756,816,412,820,000,000,000,000,000,000,000 | 23 | Fix unmatched array length in core_java.c (issue #16304) (#16313) |
static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
struct stream *s, struct attr *attr,
uint8_t attrtype)
{
unsigned int attrlenfield = 0;
unsigned int attrhdrlen = 0;
struct bgp_attr_encap_subtlv *subtlvs;
struct bgp_attr_encap_subtlv *st;
const char *attrname;
if (!attr || (attrtype == BGP_ATTR_ENCAP
&& (!attr->encap_tunneltype
|| attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS)))
return;
switch (attrtype) {
case BGP_ATTR_ENCAP:
attrname = "Tunnel Encap";
subtlvs = attr->encap_subtlvs;
if (subtlvs == NULL) /* nothing to do */
return;
/*
* The tunnel encap attr has an "outer" tlv.
* T = tunneltype,
* L = total length of subtlvs,
* V = concatenated subtlvs.
*/
attrlenfield = 2 + 2; /* T + L */
attrhdrlen = 1 + 1; /* subTLV T + L */
break;
#if ENABLE_BGP_VNC_ATTR
case BGP_ATTR_VNC:
attrname = "VNC";
subtlvs = attr->vnc_subtlvs;
if (subtlvs == NULL) /* nothing to do */
return;
attrlenfield = 0; /* no outer T + L */
attrhdrlen = 2 + 2; /* subTLV T + L */
break;
#endif
default:
assert(0);
}
/* compute attr length */
for (st = subtlvs; st; st = st->next) {
attrlenfield += (attrhdrlen + st->length);
}
if (attrlenfield > 0xffff) {
zlog_info("%s attribute is too long (length=%d), can't send it",
attrname, attrlenfield);
return;
}
if (attrlenfield > 0xff) {
/* 2-octet length field */
stream_putc(s,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, attrtype);
stream_putw(s, attrlenfield & 0xffff);
} else {
/* 1-octet length field */
stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL);
stream_putc(s, attrtype);
stream_putc(s, attrlenfield & 0xff);
}
if (attrtype == BGP_ATTR_ENCAP) {
/* write outer T+L */
stream_putw(s, attr->encap_tunneltype);
stream_putw(s, attrlenfield - 4);
}
/* write each sub-tlv */
for (st = subtlvs; st; st = st->next) {
if (attrtype == BGP_ATTR_ENCAP) {
stream_putc(s, st->type);
stream_putc(s, st->length);
#if ENABLE_BGP_VNC
} else {
stream_putw(s, st->type);
stream_putw(s, st->length);
#endif
}
stream_put(s, st->value, st->length);
}
} | 0 | [
"CWE-20",
"CWE-436"
]
| frr | 943d595a018e69b550db08cccba1d0778a86705a | 210,993,703,588,243,470,000,000,000,000,000,000,000 | 91 | bgpd: don't use BGP_ATTR_VNC(255) unless ENABLE_BGP_VNC_ATTR is defined
Signed-off-by: Lou Berger <[email protected]> |
static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
{
int err;
err = snd_c400_create_vol_ctls(mixer);
if (err < 0)
return err;
err = snd_c400_create_effect_vol_ctls(mixer);
if (err < 0)
return err;
err = snd_c400_create_effect_ret_vol_ctls(mixer);
if (err < 0)
return err;
err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
if (err < 0)
return err;
err = snd_c400_create_effect_volume_ctl(mixer);
if (err < 0)
return err;
err = snd_c400_create_effect_duration_ctl(mixer);
if (err < 0)
return err;
err = snd_c400_create_effect_feedback_ctl(mixer);
if (err < 0)
return err;
return 0;
} | 0 | []
| sound | 447d6275f0c21f6cc97a88b3a0c601436a4cdf2a | 119,903,066,874,553,810,000,000,000,000,000,000,000 | 34 | ALSA: usb-audio: Add sanity checks for endpoint accesses
Add some sanity check codes before actually accessing the endpoint via
get_endpoint() in order to avoid the invalid access through a
malformed USB descriptor. Mostly just checking bNumEndpoints, but in
one place (snd_microii_spdif_default_get()), the validity of iface and
altsetting index is checked as well.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=971125
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]> |
static void smack_cred_getsecid(const struct cred *cred, u32 *secid)
{
struct smack_known *skp;
rcu_read_lock();
skp = smk_of_task(smack_cred(cred));
*secid = skp->smk_secid;
rcu_read_unlock();
} | 0 | [
"CWE-416"
]
| linux | a3727a8bac0a9e77c70820655fd8715523ba3db7 | 330,164,274,086,181,700,000,000,000,000,000,000,000 | 9 | selinux,smack: fix subjective/objective credential use mixups
Jann Horn reported a problem with commit eb1231f73c4d ("selinux:
clarify task subjective and objective credentials") where some LSM
hooks were attempting to access the subjective credentials of a task
other than the current task. Generally speaking, it is not safe to
access another task's subjective credentials and doing so can cause
a number of problems.
Further, while looking into the problem, I realized that Smack was
suffering from a similar problem brought about by a similar commit
1fb057dcde11 ("smack: differentiate between subjective and objective
task credentials").
This patch addresses this problem by restoring the use of the task's
objective credentials in those cases where the task is other than the
current executing task. Not only does this resolve the problem
reported by Jann, it is arguably the correct thing to do in these
cases.
Cc: [email protected]
Fixes: eb1231f73c4d ("selinux: clarify task subjective and objective credentials")
Fixes: 1fb057dcde11 ("smack: differentiate between subjective and objective task credentials")
Reported-by: Jann Horn <[email protected]>
Acked-by: Eric W. Biederman <[email protected]>
Acked-by: Casey Schaufler <[email protected]>
Signed-off-by: Paul Moore <[email protected]> |
int session_info_get_fd(struct session_info *si)
{
return sd_login_monitor_get_fd(si->mon);
} | 0 | [
"CWE-362"
]
| spice-vd_agent | 5c50131797e985d0a5654c1fd7000ae945ed29a7 | 248,562,099,497,631,900,000,000,000,000,000,000,000 | 4 | Better check for sessions
Do not allow other users to hijack a session checking that
the process is launched by the owner of the session.
Signed-off-by: Frediano Ziglio <[email protected]>
Acked-by: Uri Lublin <[email protected]> |
my_decimal *Item_default_value::val_decimal(my_decimal *decimal_value)
{
calculate();
return Item_field::val_decimal(decimal_value);
} | 0 | [
"CWE-416"
]
| server | c02ebf3510850ba78a106be9974c94c3b97d8585 | 86,888,916,713,689,900,000,000,000,000,000,000,000 | 5 | 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. |
poly_box(PG_FUNCTION_ARGS)
{
POLYGON *poly = PG_GETARG_POLYGON_P(0);
BOX *box;
if (poly->npts < 1)
PG_RETURN_NULL();
box = box_copy(&poly->boundbox);
PG_RETURN_BOX_P(box);
} | 0 | [
"CWE-703",
"CWE-189"
]
| postgres | 31400a673325147e1205326008e32135a78b4d8a | 190,840,456,166,420,050,000,000,000,000,000,000,000 | 12 | Predict integer overflow to avoid buffer overruns.
Several functions, mostly type input functions, calculated an allocation
size such that the calculation wrapped to a small positive value when
arguments implied a sufficiently-large requirement. Writes past the end
of the inadvertent small allocation followed shortly thereafter.
Coverity identified the path_in() vulnerability; code inspection led to
the rest. In passing, add check_stack_depth() to prevent stack overflow
in related functions.
Back-patch to 8.4 (all supported versions). The non-comment hstore
changes touch code that did not exist in 8.4, so that part stops at 9.0.
Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
Security: CVE-2014-0064 |
vhost_user_reset_owner(struct virtio_net **pdev,
struct VhostUserMsg *msg __rte_unused,
int main_fd __rte_unused)
{
struct virtio_net *dev = *pdev;
vhost_destroy_device_notify(dev);
cleanup_device(dev, 0);
reset_device(dev);
return RTE_VHOST_MSG_RESULT_OK;
} | 1 | []
| dpdk | bf472259dde6d9c4dd3ebad2c2b477a168c6e021 | 157,879,196,002,467,680,000,000,000,000,000,000,000 | 11 | vhost: fix possible denial of service by leaking FDs
A malicious Vhost-user master could send in loop hand-crafted
vhost-user messages containing more file descriptors the
vhost-user slave expects. Doing so causes the application using
the vhost-user library to run out of FDs.
This issue has been assigned CVE-2019-14818
Fixes: 8f972312b8f4 ("vhost: support vhost-user")
Signed-off-by: Maxime Coquelin <[email protected]> |
GF_Err dimm_Write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_DIMMBox *ptr = (GF_DIMMBox *)s;
if (ptr == NULL) return GF_BAD_PARAM;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
gf_bs_write_u64(bs, ptr->nbBytes);
return GF_OK;
} | 0 | [
"CWE-400",
"CWE-401"
]
| gpac | d2371b4b204f0a3c0af51ad4e9b491144dd1225c | 210,123,036,978,065,440,000,000,000,000,000,000,000 | 10 | prevent dref memleak on invalid input (#1183) |
mrb_f_send(mrb_state *mrb, mrb_value self)
{
mrb_sym name;
mrb_value block, *regs;
mrb_method_t m;
struct RClass *c;
mrb_callinfo *ci = mrb->c->ci;
int n = ci->n;
if (ci->cci > CINFO_NONE) {
funcall:;
const mrb_value *argv;
mrb_int argc;
mrb_get_args(mrb, "n*&", &name, &argv, &argc, &block);
return mrb_funcall_with_block(mrb, self, name, argc, argv, block);
}
regs = mrb->c->ci->stack+1;
if (n == 0) {
argnum_error:
mrb_argnum_error(mrb, 0, 1, -1);
}
else if (n == 15) {
if (RARRAY_LEN(regs[0]) == 0) goto argnum_error;
name = mrb_obj_to_sym(mrb, RARRAY_PTR(regs[0])[0]);
}
else {
name = mrb_obj_to_sym(mrb, regs[0]);
}
c = mrb_class(mrb, self);
m = mrb_method_search_vm(mrb, &c, name);
if (MRB_METHOD_UNDEF_P(m)) { /* call method_mising */
goto funcall;
}
ci->mid = name;
ci->u.target_class = c;
/* remove first symbol from arguments */
if (n == 15) { /* variable length arguments */
regs[0] = mrb_ary_subseq(mrb, regs[0], 1, RARRAY_LEN(regs[0]) - 1);
}
else { /* n > 0 */
for (int i=0; i<n; i++) {
regs[i] = regs[i+1];
}
regs[n] = regs[n+1]; /* copy kdict or block */
if (ci->nk > 0) {
regs[n+1] = regs[n+2]; /* copy block */
}
ci->n--;
}
if (MRB_METHOD_CFUNC_P(m)) {
if (MRB_METHOD_NOARG_P(m)) {
check_method_noarg(mrb, ci);
}
if (MRB_METHOD_PROC_P(m)) {
mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));
}
return MRB_METHOD_CFUNC(m)(mrb, self);
}
return exec_irep(mrb, self, MRB_METHOD_PROC(m));
} | 0 | [
"CWE-122",
"CWE-787"
]
| mruby | 47068ae07a5fa3aa9a1879cdfe98a9ce0f339299 | 8,584,623,441,398,876,000,000,000,000,000,000,000 | 66 | vm.c: packed arguments length may be zero for `send` method. |
TPM_RESULT SWTPM_NVRAM_Set_MigrationKey(const unsigned char *key,
uint32_t keylen,
enum encryption_mode encmode)
{
TPM_RESULT rc;
rc = SWTPM_NVRAM_KeyParamCheck(keylen, encmode);
if (rc == 0) {
memcpy(migrationkey.symkey.userKey, key, keylen);
migrationkey.symkey.userKeyLength = keylen;
migrationkey.data_encmode = encmode;
}
return rc;
} | 0 | []
| swtpm | cae5991423826f21b11f7a5bc7f7b2b538bde2a2 | 125,373,572,026,180,090,000,000,000,000,000,000,000 | 16 | swtpm: Do not follow symlinks when opening lockfile (CVE-2020-28407)
This patch addresses CVE-2020-28407.
Prevent us from following symliks when we open the lockfile
for writing.
Signed-off-by: Stefan Berger <[email protected]> |
parse_content_range (const char *hdr, wgint *first_byte_ptr,
wgint *last_byte_ptr, wgint *entity_length_ptr)
{
wgint num;
/* Ancient versions of Netscape proxy server, presumably predating
rfc2068, sent out `Content-Range' without the "bytes"
specifier. */
if (0 == strncasecmp (hdr, "bytes", 5))
{
hdr += 5;
/* "JavaWebServer/1.1.1" sends "bytes: x-y/z", contrary to the
HTTP spec. */
if (*hdr == ':')
++hdr;
while (c_isspace (*hdr))
++hdr;
if (!*hdr)
return false;
}
if (!c_isdigit (*hdr))
return false;
for (num = 0; c_isdigit (*hdr); hdr++)
num = 10 * num + (*hdr - '0');
if (*hdr != '-' || !c_isdigit (*(hdr + 1)))
return false;
*first_byte_ptr = num;
++hdr;
for (num = 0; c_isdigit (*hdr); hdr++)
num = 10 * num + (*hdr - '0');
if (*hdr != '/')
return false;
*last_byte_ptr = num;
if (!(c_isdigit (*(hdr + 1)) || *(hdr + 1) == '*'))
return false;
if (*last_byte_ptr < *first_byte_ptr)
return false;
++hdr;
if (*hdr == '*')
num = -1;
else
for (num = 0; c_isdigit (*hdr); hdr++)
num = 10 * num + (*hdr - '0');
*entity_length_ptr = num;
if ((*entity_length_ptr <= *last_byte_ptr) && *entity_length_ptr != -1)
return false;
return true;
} | 0 | [
"CWE-119"
]
| wget | d892291fb8ace4c3b734ea5125770989c215df3f | 4,080,117,649,741,193,000,000,000,000,000,000,000 | 48 | Fix stack overflow in HTTP protocol handling (CVE-2017-13089)
* src/http.c (skip_short_body): Return error 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 *find_audio_control_unit(struct mixer_build *state,
unsigned char unit)
{
/* we just parse the header */
struct uac_feature_unit_descriptor *hdr = NULL;
while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr,
USB_DT_CS_INTERFACE)) != NULL) {
if (hdr->bLength >= 4 &&
hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL &&
hdr->bDescriptorSubtype <= UAC3_SAMPLE_RATE_CONVERTER &&
hdr->bUnitID == unit)
return hdr;
}
return NULL;
} | 0 | [
"CWE-674"
]
| sound | 19bce474c45be69a284ecee660aa12d8f1e88f18 | 114,884,989,285,348,200,000,000,000,000,000,000,000 | 17 | ALSA: usb-audio: Fix a stack buffer overflow bug in check_input_term
`check_input_term` recursively calls itself with input from
device side (e.g., uac_input_terminal_descriptor.bCSourceID)
as argument (id). In `check_input_term`, if `check_input_term`
is called with the same `id` argument as the caller, it triggers
endless recursive call, resulting kernel space stack overflow.
This patch fixes the bug by adding a bitmap to `struct mixer_build`
to keep track of the checked ids and stop the execution if some id
has been checked (similar to how parse_audio_unit handles unitid
argument).
Reported-by: Hui Peng <[email protected]>
Reported-by: Mathias Payer <[email protected]>
Signed-off-by: Hui Peng <[email protected]>
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]> |
iasecc_get_challenge(struct sc_card *card, u8 * rnd, size_t len)
{
/* As IAS/ECC cannot handle other data length than 0x08 */
u8 rbuf[8];
size_t out_len;
int r;
LOG_FUNC_CALLED(card->ctx);
r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
if (len < (size_t) r) {
out_len = len;
} else {
out_len = (size_t) r;
}
memcpy(rnd, rbuf, out_len);
LOG_FUNC_RETURN(card->ctx, (int) out_len);
} | 0 | []
| OpenSC | ae1cf0be90396fb6c0be95829bf0d3eecbd2fd1c | 261,201,501,953,976,220,000,000,000,000,000,000,000 | 21 | iasecc: Prevent stack buffer overflow when empty ACL is returned
Thanks oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30800 |
static char *setup_next_processed_event(GList **events_list)
{
free(g_event_selected);
g_event_selected = NULL;
char *event = get_next_processed_event(&g_auto_event_list);
if (!event)
{
/* No next event, go to progress page and finish */
gtk_label_set_text(g_lbl_event_log, _("Processing finished."));
/* we don't know the result of the previous event here
* so at least hide the spinner, because we're obviously finished
*/
gtk_widget_hide(GTK_WIDGET(g_spinner_event_log));
hide_next_step_button();
return NULL;
}
log_notice("selected -e EVENT:%s", event);
return event;
} | 0 | [
"CWE-200"
]
| libreport | 257578a23d1537a2d235aaa2b1488ee4f818e360 | 32,843,400,047,853,256,000,000,000,000,000,000,000 | 21 | wizard: fix save users changes after reviewing dump dir files
If the user reviewed the dump dir's files during reporting the crash, the
changes was thrown away and original data was passed to the bugzilla bug
report.
report-gtk saves the first text view buffer and then reloads data from the
reported problem directory, which causes that the changes made to those text
views are thrown away.
Function save_text_if_changed(), except of saving text, also reload the files
from dump dir and update gui state from the dump dir. The commit moves the
reloading and updating gui functions away from this function.
Related to rhbz#1270235
Signed-off-by: Matej Habrnal <[email protected]> |
http_add_field(http_t *http, /* I - HTTP connection */
http_field_t field, /* I - HTTP field */
const char *value, /* I - Value string */
int append) /* I - Append value? */
{
char newvalue[1024]; /* New value string */
const char *oldvalue; /* Old field value */
/*
* Optionally append the new value to the existing one...
*/
if (append && field != HTTP_FIELD_ACCEPT_ENCODING && field != HTTP_FIELD_ACCEPT_LANGUAGE && field != HTTP_FIELD_ACCEPT_RANGES && field != HTTP_FIELD_ALLOW && field != HTTP_FIELD_LINK && field != HTTP_FIELD_TRANSFER_ENCODING && field != HTTP_FIELD_UPGRADE && field != HTTP_FIELD_WWW_AUTHENTICATE)
append = 0;
if (field == HTTP_FIELD_HOST)
{
/*
* Special-case for Host: as we don't want a trailing "." on the hostname and
* need to bracket IPv6 numeric addresses.
*/
char *ptr = strchr(value, ':');
if (value[0] != '[' && ptr && strchr(ptr + 1, ':'))
{
/*
* Bracket IPv6 numeric addresses...
*/
snprintf(newvalue, sizeof(newvalue), "[%s]", value);
value = newvalue;
}
else if (*value && value[strlen(value) - 1] == '.')
{
/*
* Strip the trailing dot on the hostname...
*/
strlcpy(newvalue, value, sizeof(newvalue));
newvalue[strlen(newvalue) - 1] = '\0';
value = newvalue;
}
}
else if (append && *value && (oldvalue = httpGetField(http, field)) != NULL && *oldvalue)
{
snprintf(newvalue, sizeof(newvalue), "%s, %s", oldvalue, value);
value = newvalue;
}
/*
* Save the new value...
*/
switch (field)
{
case HTTP_FIELD_ACCEPT_ENCODING :
if (http->accept_encoding)
_cupsStrFree(http->accept_encoding);
http->accept_encoding = _cupsStrAlloc(value);
break;
case HTTP_FIELD_ALLOW :
if (http->allow)
_cupsStrFree(http->allow);
http->allow = _cupsStrAlloc(value);
break;
case HTTP_FIELD_SERVER :
if (http->server)
_cupsStrFree(http->server);
http->server = _cupsStrAlloc(value);
break;
case HTTP_FIELD_AUTHENTICATION_INFO :
if (http->authentication_info)
_cupsStrFree(http->authentication_info);
http->authentication_info = _cupsStrAlloc(value);
break;
default :
strlcpy(http->fields[field], value, HTTP_MAX_VALUE);
break;
}
if (field == HTTP_FIELD_AUTHORIZATION)
{
/*
* Special case for Authorization: as its contents can be
* longer than HTTP_MAX_VALUE
*/
if (http->field_authorization)
free(http->field_authorization);
http->field_authorization = strdup(value);
}
#ifdef HAVE_LIBZ
else if (field == HTTP_FIELD_CONTENT_ENCODING &&
http->data_encoding != HTTP_ENCODING_FIELDS)
{
DEBUG_puts("1http_add_field: Calling http_content_coding_start.");
http_content_coding_start(http, value);
}
#endif /* HAVE_LIBZ */
} | 0 | [
"CWE-120"
]
| cups | f24e6cf6a39300ad0c3726a41a4aab51ad54c109 | 331,678,562,256,778,600,000,000,000,000,000,000,000 | 112 | Fix multiple security/disclosure issues:
- CVE-2019-8696 and CVE-2019-8675: Fixed SNMP buffer overflows (rdar://51685251)
- Fixed IPP buffer overflow (rdar://50035411)
- Fixed memory disclosure issue in the scheduler (rdar://51373853)
- Fixed DoS issues in the scheduler (rdar://51373929) |
static ut64 compute_addr(RBin *bin, ut64 paddr, ut64 vaddr, int va) {
return paddr == UT64_MAX? vaddr: rva (bin, paddr, vaddr, va);
} | 0 | [
"CWE-78"
]
| radare2 | 5411543a310a470b1257fb93273cdd6e8dfcb3af | 269,671,262,622,687,860,000,000,000,000,000,000,000 | 3 | More fixes for the CVE-2019-14745 |
void MainWindow::on_actionSync_triggered()
{
auto dialog = new SystemSyncDialog(this);
dialog->show();
dialog->raise();
dialog->activateWindow();
} | 0 | [
"CWE-89",
"CWE-327",
"CWE-295"
]
| shotcut | f008adc039642307f6ee3378d378cdb842e52c1d | 337,368,989,274,416,750,000,000,000,000,000,000,000 | 7 | fix upgrade check is not using TLS correctly |
static inline int copy_regset_from_user(struct task_struct *target,
const struct user_regset_view *view,
unsigned int setno,
unsigned int offset, unsigned int size,
const void __user *data)
{
const struct user_regset *regset = &view->regsets[setno];
if (!regset->set)
return -EOPNOTSUPP;
if (!access_ok(VERIFY_READ, data, size))
return -EIO;
return regset->set(target, regset, offset, size, NULL, data);
} | 0 | [
"CWE-476"
]
| linux | c8e252586f8d5de906385d8cf6385fee289a825e | 133,158,751,634,597,940,000,000,000,000,000,000,000 | 16 | regset: Prevent null pointer reference on readonly regsets
The regset common infrastructure assumed that regsets would always
have .get and .set methods, but not necessarily .active methods.
Unfortunately people have since written regsets without .set methods.
Rather than putting in stub functions everywhere, handle regsets with
null .get or .set methods explicitly.
Signed-off-by: H. Peter Anvin <[email protected]>
Reviewed-by: Oleg Nesterov <[email protected]>
Acked-by: Roland McGrath <[email protected]>
Cc: <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
PERL_STATIC_INLINE UV
S_invlist_highest(SV* const invlist)
{
/* Returns the highest code point that matches an inversion list. This API
* has an ambiguity, as it returns 0 under either the highest is actually
* 0, or if the list is empty. If this distinction matters to you, check
* for emptiness before calling this function */
UV len = _invlist_len(invlist);
UV *array;
PERL_ARGS_ASSERT_INVLIST_HIGHEST;
if (len == 0) {
return 0;
}
array = invlist_array(invlist);
/* The last element in the array in the inversion list always starts a
* range that goes to infinity. That range may be for code points that are
* matched in the inversion list, or it may be for ones that aren't
* matched. In the latter case, the highest code point in the set is one
* less than the beginning of this range; otherwise it is the final element
* of this range: infinity */
return (ELEMENT_RANGE_MATCHES_INVLIST(len - 1))
? UV_MAX
: array[len - 1] - 1; | 0 | [
"CWE-190",
"CWE-787"
]
| perl5 | 897d1f7fd515b828e4b198d8b8bef76c6faf03ed | 130,740,239,630,977,500,000,000,000,000,000,000,000 | 28 | regcomp.c: Prevent integer overflow from nested regex quantifiers.
(CVE-2020-10543) On 32bit systems the size calculations for nested regular
expression quantifiers could overflow causing heap memory corruption.
Fixes: Perl/perl5-security#125
(cherry picked from commit bfd31397db5dc1a5c5d3e0a1f753a4f89a736e71) |
nautilus_mime_file_opens_in_external_app (NautilusFile *file)
{
ActivationAction activation_action;
activation_action = get_activation_action (file);
return (activation_action == ACTIVATION_ACTION_OPEN_IN_APPLICATION);
} | 0 | [
"CWE-20"
]
| nautilus | 1630f53481f445ada0a455e9979236d31a8d3bb0 | 336,010,926,062,517,230,000,000,000,000,000,000,000 | 8 | mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991 |
lspci_process_line(const char *line, void *data)
{
UNUSED(data);
char *lspci_command[5] = { "lspci", "-m", "-n", "-v", NULL };
if (!strcmp(line, "LSPCI"))
{
memset(¤t_device, 0, sizeof(current_device));
subprocess(lspci_command, handle_child_line, NULL);
/* Send single dot to indicate end of enumeration */
lspci_send(".\n");
}
else
{
logger(Core, Error, "lspci_process_line(), invalid line '%s'", line);
}
return True;
} | 0 | [
"CWE-119",
"CWE-125",
"CWE-703",
"CWE-787"
]
| rdesktop | 4dca546d04321a610c1835010b5dad85163b65e1 | 155,830,995,041,411,400,000,000,000,000,000,000,000 | 18 | Malicious RDP server security fixes
This commit includes fixes for a set of 21 vulnerabilities in
rdesktop when a malicious RDP server is used.
All vulnerabilities was identified and reported by Eyal Itkin.
* Add rdp_protocol_error function that is used in several fixes
* Refactor of process_bitmap_updates
* Fix possible integer overflow in s_check_rem() on 32bit arch
* Fix memory corruption in process_bitmap_data - CVE-2018-8794
* Fix remote code execution in process_bitmap_data - CVE-2018-8795
* Fix remote code execution in process_plane - CVE-2018-8797
* Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175
* Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175
* Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176
* Fix Denial of Service in sec_recv - CVE-2018-20176
* Fix minor information leak in rdpdr_process - CVE-2018-8791
* Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792
* Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793
* Fix Denial of Service in process_bitmap_data - CVE-2018-8796
* Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798
* Fix Denial of Service in process_secondary_order - CVE-2018-8799
* Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800
* Fix major information leak in ui_clip_handle_data - CVE-2018-20174
* Fix memory corruption in rdp_in_unistr - CVE-2018-20177
* Fix Denial of Service in process_demand_active - CVE-2018-20178
* Fix remote code execution in lspci_process - CVE-2018-20179
* Fix remote code execution in rdpsnddbg_process - CVE-2018-20180
* Fix remote code execution in seamless_process - CVE-2018-20181
* Fix remote code execution in seamless_process_line - CVE-2018-20182 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
auto* params =
reinterpret_cast<TfLiteLocalResponseNormParams*>(node->builtin_data);
const TfLiteTensor* input;
TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input));
TfLiteTensor* output;
TF_LITE_ENSURE_OK(context,
GetOutputSafe(context, node, kOutputTensor, &output));
if (output->type == kTfLiteFloat32) {
#define TF_LITE_LOCAL_RESPONSE_NORM(type) \
tflite::LocalResponseNormalizationParams op_params; \
op_params.range = params->radius; \
op_params.bias = params->bias; \
op_params.alpha = params->alpha; \
op_params.beta = params->beta; \
type::LocalResponseNormalization( \
op_params, GetTensorShape(input), GetTensorData<float>(input), \
GetTensorShape(output), GetTensorData<float>(output))
if (kernel_type == kReference) {
TF_LITE_LOCAL_RESPONSE_NORM(reference_ops);
}
if (kernel_type == kGenericOptimized) {
TF_LITE_LOCAL_RESPONSE_NORM(optimized_ops);
}
#undef TF_LITE_LOCAL_RESPONSE_NORM
} else {
context->ReportError(context, "Output type is %d, requires float.",
output->type);
return kTfLiteError;
}
return kTfLiteOk;
} | 0 | [
"CWE-125",
"CWE-787"
]
| tensorflow | 1970c2158b1ffa416d159d03c3370b9a462aee35 | 236,263,096,873,306,400,000,000,000,000,000,000,000 | 35 | [tflite]: Insert `nullptr` checks when obtaining tensors.
As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages.
We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`).
PiperOrigin-RevId: 332521299
Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56 |
inline float PrintOneElement(bfloat16 f, bool print_v2) {
return static_cast<float>(f);
} | 0 | [
"CWE-345"
]
| tensorflow | abcced051cb1bd8fb05046ac3b6023a7ebcc4578 | 67,907,905,303,713,760,000,000,000,000,000,000,000 | 3 | Prevent crashes when loading tensor slices with unsupported types.
Also fix the `Tensor(const TensorShape&)` constructor swapping the LOG(FATAL)
messages for the unset and unsupported types.
PiperOrigin-RevId: 392695027
Change-Id: I4beda7db950db951d273e3259a7c8534ece49354 |
static unsigned char *DecodeImage(Image *blob,Image *image,
size_t bytes_per_line,const unsigned int bits_per_pixel,size_t *extent,
ExceptionInfo *exception)
{
MagickSizeType
number_pixels;
register ssize_t
i;
register unsigned char
*p,
*q;
size_t
bytes_per_pixel,
length,
row_bytes,
scanline_length,
width;
ssize_t
count,
j,
y;
unsigned char
*pixels,
*scanline;
/*
Determine pixel buffer size.
*/
if (bits_per_pixel <= 8)
bytes_per_line&=0x7fff;
width=image->columns;
bytes_per_pixel=1;
if (bits_per_pixel == 16)
{
bytes_per_pixel=2;
width*=2;
}
else
if (bits_per_pixel == 32)
width*=image->alpha_trait ? 4 : 3;
if (bytes_per_line == 0)
bytes_per_line=width;
row_bytes=(size_t) (image->columns | 0x8000);
if (image->storage_class == DirectClass)
row_bytes=(size_t) ((4*image->columns) | 0x8000);
/*
Allocate pixel and scanline buffer.
*/
pixels=(unsigned char *) AcquireQuantumMemory(image->rows,row_bytes*
sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
return((unsigned char *) NULL);
*extent=row_bytes*image->rows*sizeof(*pixels);
(void) ResetMagickMemory(pixels,0,*extent);
scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,2*
sizeof(*scanline));
if (scanline == (unsigned char *) NULL)
return((unsigned char *) NULL);
if (bytes_per_line < 8)
{
/*
Pixels are already uncompressed.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
q=pixels+y*width*GetPixelChannels(image);;
number_pixels=bytes_per_line;
count=ReadBlob(blob,(size_t) number_pixels,scanline);
if (count != (ssize_t) number_pixels)
{
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",
image->filename);
break;
}
p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
if ((q+number_pixels) > (pixels+(*extent)))
{
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",
image->filename);
break;
}
(void) CopyMagickMemory(q,p,(size_t) number_pixels);
}
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
return(pixels);
}
/*
Uncompress RLE pixels into uncompressed pixel buffer.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
q=pixels+y*width;
if (bytes_per_line > 200)
scanline_length=ReadBlobMSBShort(blob);
else
scanline_length=1UL*ReadBlobByte(blob);
if (scanline_length >= row_bytes)
{
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",image->filename);
break;
}
count=ReadBlob(blob,scanline_length,scanline);
if (count != (ssize_t) scanline_length)
{
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"UnableToUncompressImage","`%s'",image->filename);
break;
}
for (j=0; j < (ssize_t) scanline_length; )
if ((scanline[j] & 0x80) == 0)
{
length=(size_t) ((scanline[j] & 0xff)+1);
number_pixels=length*bytes_per_pixel;
p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
if ((q-pixels+number_pixels) <= *extent)
(void) CopyMagickMemory(q,p,(size_t) number_pixels);
q+=number_pixels;
j+=(ssize_t) (length*bytes_per_pixel+1);
}
else
{
length=(size_t) (((scanline[j] ^ 0xff) & 0xff)+2);
number_pixels=bytes_per_pixel;
p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
for (i=0; i < (ssize_t) length; i++)
{
if ((q-pixels+number_pixels) <= *extent)
(void) CopyMagickMemory(q,p,(size_t) number_pixels);
q+=number_pixels;
}
j+=(ssize_t) bytes_per_pixel+1;
}
}
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
return(pixels);
} | 0 | [
"CWE-190",
"CWE-189",
"CWE-703"
]
| ImageMagick | 0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734 | 19,752,197,130,056,833,000,000,000,000,000,000,000 | 144 | |
TEST(SegmentSumOpModelTest, TestFailIfSegmentsAreNegative) {
SegmentSumOpModel<int32_t> model({TensorType_INT32, {3, 2}},
{TensorType_INT32, {3}});
model.PopulateTensor<int32_t>(model.data(), {1, 2, 3, 4, 5, 6});
model.PopulateTensor<int32_t>(model.segment_ids(), {-1, 0, 1});
ASSERT_EQ(model.InvokeUnchecked(), kTfLiteError);
} | 0 | [
"CWE-703",
"CWE-787"
]
| tensorflow | 204945b19e44b57906c9344c0d00120eeeae178a | 41,120,069,046,519,515,000,000,000,000,000,000,000 | 7 | [tflite] Validate segment ids for segment_sum.
Segment identifiers in segment_sum should be in a 1-D tensor of same size as the first dimension of the input. The values of the tensor should be integers from {0, 1, 2, ... k-1}, where k is the first dimension of the input. The segment identifiers must not contain jumps and must be increasing.
See https://www.tensorflow.org/api_docs/python/tf/math#Segmentation as the source for these constraints.
PiperOrigin-RevId: 332510942
Change-Id: I898beaba00642c918bcd4b4d4ce893ebb190d869 |
static void vmxnet3_set_variable_mac(VMXNET3State *s, uint32_t h, uint32_t l)
{
s->conf.macaddr.a[0] = VMXNET3_GET_BYTE(l, 0);
s->conf.macaddr.a[1] = VMXNET3_GET_BYTE(l, 1);
s->conf.macaddr.a[2] = VMXNET3_GET_BYTE(l, 2);
s->conf.macaddr.a[3] = VMXNET3_GET_BYTE(l, 3);
s->conf.macaddr.a[4] = VMXNET3_GET_BYTE(h, 0);
s->conf.macaddr.a[5] = VMXNET3_GET_BYTE(h, 1);
VMW_CFPRN("Variable MAC: " VMXNET_MF, VMXNET_MA(s->conf.macaddr.a));
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
} | 0 | [
"CWE-20"
]
| qemu | a7278b36fcab9af469563bd7b9dadebe2ae25e48 | 199,987,020,797,345,850,000,000,000,000,000,000,000 | 13 | net/vmxnet3: Refine l2 header validation
Validation of l2 header length assumed minimal packet size as
eth_header + 2 * vlan_header regardless of the actual protocol.
This caused crash for valid non-IP packets shorter than 22 bytes, as
'tx_pkt->packet_type' hasn't been assigned for such packets, and
'vmxnet3_on_tx_done_update_stats()' expects it to be properly set.
Refine header length validation in 'vmxnet_tx_pkt_parse_headers'.
Check its return value during packet processing flow.
As a side effect, in case IPv4 and IPv6 header validation failure,
corrupt packets will be dropped.
Signed-off-by: Dana Rubin <[email protected]>
Signed-off-by: Shmulik Ladkani <[email protected]>
Signed-off-by: Jason Wang <[email protected]> |
**/
CImgList<Tfloat> get_gradient(const char *const axes=0, const int scheme=3) const {
CImgList<Tfloat> grad(2,_width,_height,_depth,_spectrum);
bool is_3d = false;
if (axes) {
for (unsigned int a = 0; axes[a]; ++a) {
const char axis = cimg::lowercase(axes[a]);
switch (axis) {
case 'x' : case 'y' : break;
case 'z' : is_3d = true; break;
default :
throw CImgArgumentException(_cimg_instance
"get_gradient(): Invalid specified axis '%c'.",
cimg_instance,
axis);
}
}
} else is_3d = (_depth>1);
if (is_3d) {
CImg<Tfloat>(_width,_height,_depth,_spectrum).move_to(grad);
switch (scheme) { // 3d.
case -1 : { // Backward finite differences.
cimg_pragma_openmp(parallel for cimg_openmp_if(_width*_height*_depth>=1048576 && _spectrum>=2))
cimg_forC(*this,c) {
const ulongT off = (ulongT)c*_width*_height*_depth;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off, *ptrd2 = grad[2]._data + off;
CImg_3x3x3(I,Tfloat);
cimg_for3x3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = Iccc - Ipcc;
*(ptrd1++) = Iccc - Icpc;
*(ptrd2++) = Iccc - Iccp;
}
}
} break;
case 1 : { // Forward finite differences.
cimg_pragma_openmp(parallel for cimg_openmp_if(_width*_height*_depth>=1048576 && _spectrum>=2))
cimg_forC(*this,c) {
const ulongT off = (ulongT)c*_width*_height*_depth;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off, *ptrd2 = grad[2]._data + off;
CImg_2x2x2(I,Tfloat);
cimg_for2x2x2(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = Incc - Iccc;
*(ptrd1++) = Icnc - Iccc;
*(ptrd2++) = Iccn - Iccc;
}
}
} break;
case 4 : { // Deriche filter with low standard variation.
grad[0] = get_deriche(0,1,'x');
grad[1] = get_deriche(0,1,'y');
grad[2] = get_deriche(0,1,'z');
} break;
case 5 : { // Van Vliet filter with low standard variation.
grad[0] = get_vanvliet(0,1,'x');
grad[1] = get_vanvliet(0,1,'y');
grad[2] = get_vanvliet(0,1,'z');
} break;
default : { // Central finite differences.
cimg_pragma_openmp(parallel for cimg_openmp_if(_width*_height*_depth>=1048576 && _spectrum>=2))
cimg_forC(*this,c) {
const ulongT off = (ulongT)c*_width*_height*_depth;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off, *ptrd2 = grad[2]._data + off;
CImg_3x3x3(I,Tfloat);
cimg_for3x3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = (Incc - Ipcc)/2;
*(ptrd1++) = (Icnc - Icpc)/2;
*(ptrd2++) = (Iccn - Iccp)/2;
}
}
}
}
} else switch (scheme) { // 2d.
case -1 : { // Backward finite differences.
cimg_pragma_openmp(parallel for collapse(2) cimg_openmp_if(_width*_height>=1048576 && _depth*_spectrum>=2))
cimg_forZC(*this,z,c) {
const ulongT off = (ulongT)c*_width*_height*_depth + z*_width*_height;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off;
CImg_3x3(I,Tfloat);
cimg_for3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = Icc - Ipc;
*(ptrd1++) = Icc - Icp;
}
}
} break;
case 1 : { // Forward finite differences.
cimg_pragma_openmp(parallel for collapse(2) cimg_openmp_if(_width*_height>=1048576 && _depth*_spectrum>=2))
cimg_forZC(*this,z,c) {
const ulongT off = (ulongT)c*_width*_height*_depth + z*_width*_height;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off;
CImg_2x2(I,Tfloat);
cimg_for2x2(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = Inc - Icc;
*(ptrd1++) = Icn - Icc;
}
}
} break;
case 2 : { // Sobel scheme.
cimg_pragma_openmp(parallel for collapse(2) cimg_openmp_if(_width*_height>=1048576 && _depth*_spectrum>=2))
cimg_forZC(*this,z,c) {
const ulongT off = (ulongT)c*_width*_height*_depth + z*_width*_height;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off;
CImg_3x3(I,Tfloat);
cimg_for3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = -Ipp - 2*Ipc - Ipn + Inp + 2*Inc + Inn;
*(ptrd1++) = -Ipp - 2*Icp - Inp + Ipn + 2*Icn + Inn;
}
}
} break;
case 3 : { // Rotation invariant kernel.
cimg_pragma_openmp(parallel for collapse(2) cimg_openmp_if(_width*_height>=1048576 && _depth*_spectrum>=2))
cimg_forZC(*this,z,c) {
const ulongT off = (ulongT)c*_width*_height*_depth + z*_width*_height;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off;
CImg_3x3(I,Tfloat);
const Tfloat a = (Tfloat)(0.25f*(2 - std::sqrt(2.0f))), b = (Tfloat)(0.5f*(std::sqrt(2.0f) - 1));
cimg_for3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = -a*Ipp - b*Ipc - a*Ipn + a*Inp + b*Inc + a*Inn;
*(ptrd1++) = -a*Ipp - b*Icp - a*Inp + a*Ipn + b*Icn + a*Inn;
}
}
} break;
case 4 : { // Van Vliet filter with low standard variation
grad[0] = get_deriche(0,1,'x');
grad[1] = get_deriche(0,1,'y');
} break;
case 5 : { // Deriche filter with low standard variation
grad[0] = get_vanvliet(0,1,'x');
grad[1] = get_vanvliet(0,1,'y');
} break;
default : { // Central finite differences
cimg_pragma_openmp(parallel for collapse(2) cimg_openmp_if(_width*_height>=1048576 && _depth*_spectrum>=2))
cimg_forZC(*this,z,c) {
const ulongT off = (ulongT)c*_width*_height*_depth + z*_width*_height;
Tfloat *ptrd0 = grad[0]._data + off, *ptrd1 = grad[1]._data + off;
CImg_3x3(I,Tfloat);
cimg_for3x3(*this,x,y,z,c,I,Tfloat) {
*(ptrd0++) = (Inc - Ipc)/2;
*(ptrd1++) = (Icn - Icp)/2;
}
}
}
}
if (!axes) return grad;
CImgList<Tfloat> res;
for (unsigned int l = 0; axes[l]; ++l) {
const char axis = cimg::lowercase(axes[l]);
switch (axis) {
case 'x' : res.insert(grad[0]); break;
case 'y' : res.insert(grad[1]); break;
case 'z' : res.insert(grad[2]); break;
}
}
grad.assign();
return res; | 0 | [
"CWE-125"
]
| CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | 37,357,203,616,073,000,000,000,000,000,000,000,000 | 154 | Fix other issues in 'CImg<T>::load_bmp()'. |
virtual void __fastcall Execute()
{
unsigned long Read;
FStr.SetLength(10240);
FResult = ReadConsole(FInput, FStr.c_str(), FStr.Length(), &Read, NULL);
DebugAssert(FResult);
FStr.SetLength(Read);
TrimNewLine(FStr);
}
| 0 | [
"CWE-787"
]
| winscp | faa96e8144e6925a380f94a97aa382c9427f688d | 169,547,411,979,402,390,000,000,000,000,000,000,000 | 9 | Bug 1943: Prevent loading session settings that can lead to remote code execution from handled URLs
https://winscp.net/tracker/1943
(cherry picked from commit ec584f5189a856cd79509f754722a6898045c5e0)
Source commit: 0f4be408b3f01132b00682da72d925d6c4ee649b |
ssize_t sftp_write(sftp_file file, const void *buf, size_t count) {
sftp_session sftp = file->sftp;
sftp_message msg = NULL;
sftp_status_message status;
ssh_string datastring;
ssh_buffer buffer;
uint32_t id;
int len;
int packetlen;
buffer = ssh_buffer_new();
if (buffer == NULL) {
ssh_set_error_oom(sftp->session);
return -1;
}
datastring = ssh_string_new(count);
if (datastring == NULL) {
ssh_set_error_oom(sftp->session);
ssh_buffer_free(buffer);
return -1;
}
ssh_string_fill(datastring, buf, count);
id = sftp_get_new_id(file->sftp);
if (buffer_add_u32(buffer, id) < 0 ||
buffer_add_ssh_string(buffer, file->handle) < 0 ||
buffer_add_u64(buffer, htonll(file->offset)) < 0 ||
buffer_add_ssh_string(buffer, datastring) < 0) {
ssh_set_error_oom(sftp->session);
ssh_buffer_free(buffer);
ssh_string_free(datastring);
return -1;
}
ssh_string_free(datastring);
packetlen=buffer_get_rest_len(buffer);
len = sftp_packet_write(file->sftp, SSH_FXP_WRITE, buffer);
ssh_buffer_free(buffer);
if (len < 0) {
return -1;
} else if (len != packetlen) {
ssh_log(sftp->session, SSH_LOG_PACKET,
"Could not write as much data as expected");
}
while (msg == NULL) {
if (sftp_read_and_dispatch(file->sftp) < 0) {
/* something nasty has happened */
return -1;
}
msg = sftp_dequeue(file->sftp, id);
}
switch (msg->packet_type) {
case SSH_FXP_STATUS:
status = parse_status_msg(msg);
sftp_message_free(msg);
if (status == NULL) {
return -1;
}
sftp_set_error(sftp, status->status);
switch (status->status) {
case SSH_FX_OK:
file->offset += count;
status_msg_free(status);
return count;
default:
break;
}
ssh_set_error(sftp->session, SSH_REQUEST_DENIED,
"SFTP server: %s", status->errormsg);
file->offset += count;
status_msg_free(status);
return -1;
default:
ssh_set_error(sftp->session, SSH_FATAL,
"Received message %d during write!", msg->packet_type);
sftp_message_free(msg);
return -1;
}
return -1; /* not reached */
} | 0 | []
| libssh | 4d8420f3282ed07fc99fc5e930c17df27ef1e9b2 | 203,436,235,175,121,180,000,000,000,000,000,000,000 | 83 | sftp: Fix bug in sftp_mkdir not returning on error.
resolves: #84
(cherry picked from commit a92c97b2e17715c1b3cdd693d14af6c3311d8e44) |
static int wtp_connect(struct hid_device *hdev, bool connected)
{
struct hidpp_device *hidpp = hid_get_drvdata(hdev);
struct wtp_data *wd = hidpp->private_data;
int ret;
if (!wd->x_size) {
ret = wtp_get_config(hidpp);
if (ret) {
hid_err(hdev, "Can not get wtp config: %d\n", ret);
return ret;
}
}
return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index,
true, true);
} | 0 | [
"CWE-787"
]
| linux | d9d4b1e46d9543a82c23f6df03f4ad697dab361b | 148,887,207,453,656,200,000,000,000,000,000,000,000 | 17 | 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]> |
pfm_buf_fmt_exit(pfm_buffer_fmt_t *fmt, struct task_struct *task, void *buf, struct pt_regs *regs)
{
int ret = 0;
if (fmt->fmt_exit) ret = (*fmt->fmt_exit)(task, buf, regs);
return ret;
} | 0 | []
| linux-2.6 | 41d5e5d73ecef4ef56b7b4cde962929a712689b4 | 322,492,825,555,874,880,000,000,000,000,000,000,000 | 6 | [IA64] permon use-after-free fix
Perfmon associates vmalloc()ed memory with a file descriptor, and installs
a vma mapping that memory. Unfortunately, the vm_file field is not filled
in, so processes with mappings to that memory do not prevent the file from
being closed and the memory freed. This results in use-after-free bugs and
multiple freeing of pages, etc.
I saw this bug on an Altix on SLES9. Haven't reproduced upstream but it
looks like the same issue is there.
Signed-off-by: Nick Piggin <[email protected]>
Cc: Stephane Eranian <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Tony Luck <[email protected]> |
lacks_mount (NautilusFile *file)
{
return (!file->details->mount_is_up_to_date &&
(
/* Unix mountpoint, could be a GMount */
file->details->is_mountpoint ||
/* The toplevel directory of something */
(file->details->type == G_FILE_TYPE_DIRECTORY &&
nautilus_file_is_self_owned (file)) ||
/* Mountable with a target_uri, could be a mountpoint */
(file->details->type == G_FILE_TYPE_MOUNTABLE &&
file->details->activation_location != NULL)
)
);
} | 0 | []
| nautilus | 7632a3e13874a2c5e8988428ca913620a25df983 | 93,277,264,843,700,990,000,000,000,000,000,000,000 | 18 | Check for trusted desktop file launchers.
2009-02-24 Alexander Larsson <[email protected]>
* libnautilus-private/nautilus-directory-async.c:
Check for trusted desktop file launchers.
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.c:
* libnautilus-private/nautilus-file.h:
Add nautilus_file_is_trusted_link.
Allow unsetting of custom display name.
* libnautilus-private/nautilus-mime-actions.c:
Display dialog when trying to launch a non-trusted desktop file.
svn path=/trunk/; revision=15003 |
void Huff_transmit (huff_t *huff, int ch, byte *fout, int maxoffset) {
int i;
if (huff->loc[ch] == NULL) {
/* node_t hasn't been transmitted, send a NYT, then the symbol */
Huff_transmit(huff, NYT, fout, maxoffset);
for (i = 7; i >= 0; i--) {
add_bit((char)((ch >> i) & 0x1), fout);
}
} else {
send(huff->loc[ch], NULL, fout, maxoffset);
}
} | 0 | [
"CWE-119"
]
| ioq3 | d2b1d124d4055c2fcbe5126863487c52fd58cca1 | 280,965,075,679,946,970,000,000,000,000,000,000,000 | 12 | Fix/improve buffer overflow in MSG_ReadBits/MSG_WriteBits
Prevent reading past end of message in MSG_ReadBits. If read past
end of msg->data buffer (16348 bytes) the engine could SEGFAULT.
Make MSG_WriteBits use an exact buffer overflow check instead of
possibly failing with a few bytes left. |
static void mkiss_put(struct mkiss *ax)
{
if (refcount_dec_and_test(&ax->refcnt))
complete(&ax->dead);
} | 0 | [
"CWE-416"
]
| linux | b2f37aead1b82a770c48b5d583f35ec22aabb61e | 136,130,966,075,126,720,000,000,000,000,000,000,000 | 5 | hamradio: improve the incomplete fix to avoid NPD
The previous commit 3e0588c291d6 ("hamradio: defer ax25 kfree after
unregister_netdev") reorder the kfree operations and unregister_netdev
operation to prevent UAF.
This commit improves the previous one by also deferring the nullify of
the ax->tty pointer. Otherwise, a NULL pointer dereference bug occurs.
Partial of the stack trace is shown below.
BUG: kernel NULL pointer dereference, address: 0000000000000538
RIP: 0010:ax_xmit+0x1f9/0x400
...
Call Trace:
dev_hard_start_xmit+0xec/0x320
sch_direct_xmit+0xea/0x240
__qdisc_run+0x166/0x5c0
__dev_queue_xmit+0x2c7/0xaf0
ax25_std_establish_data_link+0x59/0x60
ax25_connect+0x3a0/0x500
? security_socket_connect+0x2b/0x40
__sys_connect+0x96/0xc0
? __hrtimer_init+0xc0/0xc0
? common_nsleep+0x2e/0x50
? switch_fpu_return+0x139/0x1a0
__x64_sys_connect+0x11/0x20
do_syscall_64+0x33/0x40
entry_SYSCALL_64_after_hwframe+0x44/0xa9
The crash point is shown as below
static void ax_encaps(...) {
...
set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); // ax->tty = NULL!
...
}
By placing the nullify action after the unregister_netdev, the ax->tty
pointer won't be assigned as NULL net_device framework layer is well
synchronized.
Signed-off-by: Lin Ma <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
*/
void
xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return;
CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER); | 0 | [
"CWE-476"
]
| libxml2 | a436374994c47b12d5de1b8b1d191a098fa23594 | 82,567,923,012,437,810,000,000,000,000,000,000,000 | 6 | Fix nullptr deref with XPath logic ops
If the XPath stack is corrupted, for example by a misbehaving extension
function, the "and" and "or" XPath operators could dereference NULL
pointers. Check that the XPath stack isn't empty and optimize the
logic operators slightly.
Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/5
Also see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901817
https://bugzilla.redhat.com/show_bug.cgi?id=1595985
This is CVE-2018-14404.
Thanks to Guy Inbar for the report. |
print_pipeline (p, job_index, format, stream)
PROCESS *p;
int job_index, format;
FILE *stream;
{
PROCESS *first, *last, *show;
int es, name_padding;
char *temp;
if (p == 0)
return;
first = last = p;
while (last->next != first)
last = last->next;
for (;;)
{
if (p != first)
fprintf (stream, format ? " " : " |");
if (format != JLIST_STANDARD)
fprintf (stream, "%5ld", (long)p->pid);
fprintf (stream, " ");
if (format > -1 && job_index >= 0)
{
show = format ? p : last;
temp = printable_job_status (job_index, show, format);
if (p != first)
{
if (format)
{
if (show->running == first->running &&
WSTATUS (show->status) == WSTATUS (first->status))
temp = "";
}
else
temp = (char *)NULL;
}
if (temp)
{
fprintf (stream, "%s", temp);
es = STRLEN (temp);
if (es == 0)
es = 2; /* strlen ("| ") */
name_padding = LONGEST_SIGNAL_DESC - es;
fprintf (stream, "%*s", name_padding, "");
if ((WIFSTOPPED (show->status) == 0) &&
(WIFCONTINUED (show->status) == 0) &&
WIFCORED (show->status))
fprintf (stream, _("(core dumped) "));
}
}
if (p != first && format)
fprintf (stream, "| ");
if (p->command)
fprintf (stream, "%s", p->command);
if (p == last && job_index >= 0)
{
temp = current_working_directory ();
if (RUNNING (job_index) && (IS_FOREGROUND (job_index) == 0))
fprintf (stream, " &");
if (strcmp (temp, jobs[job_index]->wd) != 0)
fprintf (stream,
_(" (wd: %s)"), polite_directory_format (jobs[job_index]->wd));
}
if (format || (p == last))
{
/* We need to add a CR only if this is an interactive shell, and
we're reporting the status of a completed job asynchronously.
We can't really check whether this particular job is being
reported asynchronously, so just add the CR if the shell is
currently interactive and asynchronous notification is enabled. */
if (asynchronous_notification && interactive)
fprintf (stream, "\r\n");
else
fprintf (stream, "\n");
}
if (p == last)
break;
p = p->next;
}
fflush (stream);
} | 0 | []
| bash | 955543877583837c85470f7fb8a97b7aa8d45e6c | 57,026,369,027,094,740,000,000,000,000,000,000,000 | 98 | bash-4.4-rc2 release |
static int pmu_dev_alloc(struct pmu *pmu)
{
int ret = -ENOMEM;
pmu->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!pmu->dev)
goto out;
pmu->dev->groups = pmu->attr_groups;
device_initialize(pmu->dev);
ret = dev_set_name(pmu->dev, "%s", pmu->name);
if (ret)
goto free_dev;
dev_set_drvdata(pmu->dev, pmu);
pmu->dev->bus = &pmu_bus;
pmu->dev->release = pmu_dev_release;
ret = device_add(pmu->dev);
if (ret)
goto free_dev;
out:
return ret;
free_dev:
put_device(pmu->dev);
goto out;
} | 0 | [
"CWE-703",
"CWE-189"
]
| linux | 8176cced706b5e5d15887584150764894e94e02f | 43,645,800,912,910,550,000,000,000,000,000,000,000 | 28 | perf: Treat attr.config as u64 in perf_swevent_init()
Trinity discovered that we fail to check all 64 bits of
attr.config passed by user space, resulting to out-of-bounds
access of the perf_swevent_enabled array in
sw_perf_event_destroy().
Introduced in commit b0a873ebb ("perf: Register PMU
implementations").
Signed-off-by: Tommi Rantala <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]> |
nfssvc_decode_createargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd_createargs *args)
{
if ( !(p = decode_fh(p, &args->fh))
|| !(p = decode_filename(p, &args->name, &args->len)))
return 0;
p = decode_sattr(p, &args->attrs);
return xdr_argsize_check(rqstp, p);
} | 0 | [
"CWE-119",
"CWE-703"
]
| linux | 13bf9fbff0e5e099e2b6f003a0ab8ae145436309 | 67,377,085,587,944,480,000,000,000,000,000,000,000 | 10 | nfsd: stricter decoding of write-like NFSv2/v3 ops
The NFSv2/v3 code does not systematically check whether we decode past
the end of the buffer. This generally appears to be harmless, but there
are a few places where we do arithmetic on the pointers involved and
don't account for the possibility that a length could be negative. Add
checks to catch these.
Reported-by: Tuomas Haanpää <[email protected]>
Reported-by: Ari Kauppi <[email protected]>
Reviewed-by: NeilBrown <[email protected]>
Cc: [email protected]
Signed-off-by: J. Bruce Fields <[email protected]> |
scan_unsigned_octal_number(UChar** src, UChar* end, int maxlen,
OnigEncoding enc)
{
OnigCodePoint c;
unsigned int num, val;
UChar* p = *src;
PFETCH_READY;
num = 0;
while (! PEND && maxlen-- != 0) {
PFETCH(c);
if (ONIGENC_IS_CODE_DIGIT(enc, c) && c < '8') {
val = ODIGITVAL(c);
if ((INT_MAX_LIMIT - val) / 8UL < num)
return -1; /* overflow */
num = (num << 3) + val;
}
else {
PUNFETCH;
break;
}
}
*src = p;
return num;
} | 0 | [
"CWE-787"
]
| oniguruma | ddbf55698b5f7ffdfa737b0b8e0079af1fdd7cb1 | 309,132,589,506,686,420,000,000,000,000,000,000,000 | 26 | re-fix #60 by check val_type |
rb_str_each_byte(VALUE str)
{
long i;
RETURN_ENUMERATOR(str, 0, 0);
for (i=0; i<RSTRING_LEN(str); i++) {
rb_yield(INT2FIX(RSTRING_PTR(str)[i] & 0xff));
}
return str;
} | 0 | [
"CWE-119"
]
| ruby | 1c2ef610358af33f9ded3086aa2d70aac03dcac5 | 335,617,782,185,342,380,000,000,000,000,000,000,000 | 10 | * string.c (rb_str_justify): CVE-2009-4124.
Fixes a bug reported by
Emmanouel Kellinis <Emmanouel.Kellinis AT kpmg.co.uk>, KPMG London;
Patch by nobu.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
SV *
Perl_regclass_swash(pTHX_ const regexp *prog, const regnode* node, bool doinit, SV** listsvp, SV **altsvp)
{
PERL_ARGS_ASSERT_REGCLASS_SWASH;
if (altsvp) {
*altsvp = NULL;
}
return newSVsv(_get_regclass_nonbitmap_data(prog, node, doinit, listsvp, NULL, NULL)); | 0 | [
"CWE-416"
]
| perl5 | 22b433eff9a1ffa2454e18405a56650f07b385b5 | 209,925,052,338,642,030,000,000,000,000,000,000,000 | 10 | PATCH [perl #123562] Regexp-matching "hangs"
The regex engine got into an infinite loop because of the malformation.
It is trying to back-up over a sequence of UTF-8 continuation bytes.
But the character just before the sequence should be a start byte. If
not, there is a malformation. I added a test to croak if that isn't the
case so that it doesn't just infinitely loop. I did this also in the
similar areas of regexec.c.
Comments long ago added to the code suggested that we check for
malformations in the vicinity of the new tests. But that was never
done. These new tests should be good enough to prevent looping, anyway. |
int ldb_kv_search(struct ldb_kv_context *ctx)
{
struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
void *data = ldb_module_get_private(module);
struct ldb_kv_private *ldb_kv =
talloc_get_type(data, struct ldb_kv_private);
int ret;
ldb = ldb_module_get_ctx(module);
ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ldb_kv->kv_ops->lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
if (ldb_kv_cache_load(module) != 0) {
ldb_kv->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
ldb_kv->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
ctx->tree = req->op.search.tree;
ctx->scope = req->op.search.scope;
ctx->base = req->op.search.base;
ctx->attrs = req->op.search.attrs;
if ((req->op.search.base == NULL) || (ldb_dn_is_null(req->op.search.base) == true)) {
/* Check what we should do with a NULL dn */
switch (req->op.search.scope) {
case LDB_SCOPE_BASE:
ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a base search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
case LDB_SCOPE_ONELEVEL:
ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a one-level search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
case LDB_SCOPE_SUBTREE:
default:
/* We accept subtree searches from a NULL base DN, ie over the whole DB */
ret = LDB_SUCCESS;
}
} else if (ldb_dn_is_valid(req->op.search.base) == false) {
/* We don't want invalid base DNs here */
ldb_asprintf_errstring(ldb,
"Invalid Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
ret = LDB_ERR_INVALID_DN_SYNTAX;
} else if (req->op.search.scope == LDB_SCOPE_BASE) {
/*
* If we are LDB_SCOPE_BASE, do just one search and
* return early. This is critical to ensure we do not
* go into the index code for special DNs, as that
* will try to look up an index record for a special
* record (which doesn't exist).
*/
ret = ldb_kv_search_and_return_base(ldb_kv, ctx);
ldb_kv->kv_ops->unlock_read(module);
return ret;
} else if (ldb_kv->check_base) {
/*
* This database has been marked as
* 'checkBaseOnSearch', so do a spot check of the base
* dn. Also optimise the subsequent filter by filling
* in the ctx->base to be exactly case correct
*/
ret = ldb_kv_search_base(
module, ctx, req->op.search.base, &ctx->base);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_asprintf_errstring(ldb,
"No such Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
}
} else {
/* If we are not checking the base DN life is easy */
ret = LDB_SUCCESS;
}
if (ret == LDB_SUCCESS) {
uint32_t match_count = 0;
ret = ldb_kv_search_indexed(ctx, &match_count);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/* Not in the index, therefore OK! */
ret = LDB_SUCCESS;
}
/* Check if we got just a normal error.
* In that case proceed to a full search unless we got a
* callback error */
if (!ctx->request_terminated && ret != LDB_SUCCESS) {
/* Not indexed, so we need to do a full scan */
if (ldb_kv->warn_unindexed ||
ldb_kv->disable_full_db_scan) {
/* useful for debugging when slow performance
* is caused by unindexed searches */
char *expression = ldb_filter_from_tree(ctx, ctx->tree);
ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb FULL SEARCH: %s SCOPE: %s DN: %s",
expression,
req->op.search.scope==LDB_SCOPE_BASE?"base":
req->op.search.scope==LDB_SCOPE_ONELEVEL?"one":
req->op.search.scope==LDB_SCOPE_SUBTREE?"sub":"UNKNOWN",
ldb_dn_get_linearized(req->op.search.base));
talloc_free(expression);
}
if (match_count != 0) {
/* the indexing code gave an error
* after having returned at least one
* entry. This means the indexes are
* corrupt or a database record is
* corrupt. We cannot continue with a
* full search or we may return
* duplicate entries
*/
ldb_kv->kv_ops->unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
if (ldb_kv->disable_full_db_scan) {
ldb_set_errstring(ldb,
"ldb FULL SEARCH disabled");
ldb_kv->kv_ops->unlock_read(module);
return LDB_ERR_INAPPROPRIATE_MATCHING;
}
ret = ldb_kv_search_full(ctx);
if (ret != LDB_SUCCESS) {
ldb_set_errstring(ldb, "Indexed and full searches both failed!\n");
}
}
}
ldb_kv->kv_ops->unlock_read(module);
return ret;
} | 1 | [
"CWE-20"
]
| samba | 3c1fbb18321f61df44d7b0f0c7452ae230960293 | 35,393,062,921,800,165,000,000,000,000,000,000,000 | 156 | CVE-2018-1140 ldb_tdb: Check for DN validity in add, rename and search
This ensures we fail with a good error code before an eventual ldb_dn_get_casefold() which
would otherwise fail.
Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374 |
static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)
{
if (s->io.read) {
int blen = (int) (s->img_buffer_end - s->img_buffer);
if (blen < n) {
int res, count;
memcpy(buffer, s->img_buffer, blen);
count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen);
res = (count == (n-blen));
s->img_buffer = s->img_buffer_end;
return res;
}
}
if (s->img_buffer+n <= s->img_buffer_end) {
memcpy(buffer, s->img_buffer, n);
s->img_buffer += n;
return 1;
} else
return 0;
} | 0 | [
"CWE-787"
]
| stb | 5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40 | 272,736,903,347,227,060,000,000,000,000,000,000,000 | 23 | stb_image: Reject fractional JPEG component subsampling ratios
The component resamplers are not written to support this and I've
never seen it happen in a real (non-crafted) JPEG file so I'm
fine rejecting this as outright corrupt.
Fixes issue #1178. |
CannotReadFile(const std::string &msg) : std::runtime_error(msg) { }; | 0 | [
"CWE-22"
]
| Sigil | 0979ba8d10c96ebca330715bfd4494ea0e019a8f | 331,718,114,238,874,400,000,000,000,000,000,000,000 | 1 | harden plugin unzipping to zip-slip attacks |
static i40e_status i40e_force_link_state(struct i40e_pf *pf, bool is_up)
{
struct i40e_aq_get_phy_abilities_resp abilities;
struct i40e_aq_set_phy_config config = {0};
struct i40e_hw *hw = &pf->hw;
i40e_status err;
u64 mask;
u8 speed;
/* Card might've been put in an unstable state by other drivers
* and applications, which causes incorrect speed values being
* set on startup. In order to clear speed registers, we call
* get_phy_capabilities twice, once to get initial state of
* available speeds, and once to get current PHY config.
*/
err = i40e_aq_get_phy_capabilities(hw, false, true, &abilities,
NULL);
if (err) {
dev_err(&pf->pdev->dev,
"failed to get phy cap., ret = %s last_status = %s\n",
i40e_stat_str(hw, err),
i40e_aq_str(hw, hw->aq.asq_last_status));
return err;
}
speed = abilities.link_speed;
/* Get the current phy config */
err = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,
NULL);
if (err) {
dev_err(&pf->pdev->dev,
"failed to get phy cap., ret = %s last_status = %s\n",
i40e_stat_str(hw, err),
i40e_aq_str(hw, hw->aq.asq_last_status));
return err;
}
/* If link needs to go up, but was not forced to go down,
* and its speed values are OK, no need for a flap
*/
if (is_up && abilities.phy_type != 0 && abilities.link_speed != 0)
return I40E_SUCCESS;
/* To force link we need to set bits for all supported PHY types,
* but there are now more than 32, so we need to split the bitmap
* across two fields.
*/
mask = I40E_PHY_TYPES_BITMASK;
config.phy_type = is_up ? cpu_to_le32((u32)(mask & 0xffffffff)) : 0;
config.phy_type_ext = is_up ? (u8)((mask >> 32) & 0xff) : 0;
/* Copy the old settings, except of phy_type */
config.abilities = abilities.abilities;
if (abilities.link_speed != 0)
config.link_speed = abilities.link_speed;
else
config.link_speed = speed;
config.eee_capability = abilities.eee_capability;
config.eeer = abilities.eeer_val;
config.low_power_ctrl = abilities.d3_lpan;
config.fec_config = abilities.fec_cfg_curr_mod_ext_info &
I40E_AQ_PHY_FEC_CONFIG_MASK;
err = i40e_aq_set_phy_config(hw, &config, NULL);
if (err) {
dev_err(&pf->pdev->dev,
"set phy config ret = %s last_status = %s\n",
i40e_stat_str(&pf->hw, err),
i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));
return err;
}
/* Update the link info */
err = i40e_update_link_info(hw);
if (err) {
/* Wait a little bit (on 40G cards it sometimes takes a really
* long time for link to come back from the atomic reset)
* and try once more
*/
msleep(1000);
i40e_update_link_info(hw);
}
i40e_aq_set_link_restart_an(hw, true, NULL);
return I40E_SUCCESS;
} | 0 | [
"CWE-400",
"CWE-401"
]
| linux | 27d461333459d282ffa4a2bdb6b215a59d493a8f | 242,819,165,174,591,770,000,000,000,000,000,000,000 | 86 | i40e: prevent memory leak in i40e_setup_macvlans
In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory
for ch should be released.
Signed-off-by: Navid Emamdoost <[email protected]>
Tested-by: Andrew Bowers <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]> |
bool vnc_has_job(VncState *vs)
{
bool ret;
vnc_lock_queue(queue);
ret = vnc_has_job_locked(vs);
vnc_unlock_queue(queue);
return ret;
} | 0 | [
"CWE-125"
]
| qemu | 9f64916da20eea67121d544698676295bbb105a7 | 201,170,432,106,708,350,000,000,000,000,000,000,000 | 9 | pixman/vnc: use pixman images in vnc.
The vnc code uses *three* DisplaySurfaces:
First is the surface of the actual QemuConsole, usually the guest
screen, but could also be a text console (monitor/serial reachable via
Ctrl-Alt-<nr> keys). This is left as-is.
Second is the current server's view of the screen content. The vnc code
uses this to figure which parts of the guest screen did _really_ change
to reduce the amount of updates sent to the vnc clients. It is also
used as data source when sending out the updates to the clients. This
surface gets replaced by a pixman image. The format changes too,
instead of using the guest screen format we'll use fixed 32bit rgb
framebuffer and convert the pixels on the fly when comparing and
updating the server framebuffer.
Third surface carries the format expected by the vnc client. That isn't
used to store image data. This surface is switched to PixelFormat and a
boolean for bigendian byte order.
Signed-off-by: Gerd Hoffmann <[email protected]> |
int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
struct kvec *vec, size_t num, size_t size, int flags)
{
mm_segment_t oldfs = get_fs();
int result;
set_fs(KERNEL_DS);
/*
* the following is safe, since for compiler definitions of kvec and
* iovec are identical, yielding the same in-core layout and alignment
*/
iov_iter_init(&msg->msg_iter, READ, (struct iovec *)vec, num, size);
result = sock_recvmsg(sock, msg, size, flags);
set_fs(oldfs);
return result;
} | 0 | [
"CWE-264"
]
| net | 4de930efc23b92ddf88ce91c405ee645fe6e27ea | 171,908,749,023,742,140,000,000,000,000,000,000,000 | 16 | net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom
Cc: [email protected] # v3.19
Signed-off-by: Al Viro <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
save_8 (FILE *fp,
gint width,
gint height,
const guchar *buffer)
{
int row;
for (row = 0; row < height; ++row)
{
writeline (fp, buffer, width);
buffer += width;
gimp_progress_update ((double) row / (double) height);
}
} | 0 | [
"CWE-190"
]
| gimp | a9671395f6573e90316a9d748588c5435216f6ce | 89,759,487,013,921,830,000,000,000,000,000,000,000 | 14 | PCX: Avoid allocation overflows.
Multiplying gint values may overflow unless cast into a larger type. |
static int bind_ubo_locs(struct vrend_linked_shader_program *sprog,
int id, int next_ubo_id)
{
if (!has_feature(feat_ubo))
return next_ubo_id;
if (sprog->ss[id]->sel->sinfo.ubo_used_mask) {
const char *prefix = pipe_shader_to_prefix(id);
unsigned mask = sprog->ss[id]->sel->sinfo.ubo_used_mask;
while (mask) {
uint32_t ubo_idx = u_bit_scan(&mask);
char name[32];
if (sprog->ss[id]->sel->sinfo.ubo_indirect)
snprintf(name, 32, "%subo[%d]", prefix, ubo_idx - 1);
else
snprintf(name, 32, "%subo%d", prefix, ubo_idx);
GLuint loc = glGetUniformBlockIndex(sprog->id, name);
glUniformBlockBinding(sprog->id, loc, next_ubo_id++);
}
}
sprog->ubo_used_mask[id] = sprog->ss[id]->sel->sinfo.ubo_used_mask;
return next_ubo_id;
} | 0 | [
"CWE-787"
]
| virglrenderer | cbc8d8b75be360236cada63784046688aeb6d921 | 86,822,220,664,292,710,000,000,000,000,000,000,000 | 26 | vrend: check transfer bounds for negative values too and report error
Closes #138
Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Emil Velikov <[email protected]> |
calc_enc_length (gnutls_session_t session, int data_size,
int hash_size, uint8_t * pad, int random_pad,
unsigned block_algo, unsigned auth_cipher, uint16_t blocksize)
{
uint8_t rnd;
unsigned int length;
int ret;
*pad = 0;
switch (block_algo)
{
case CIPHER_STREAM:
length = data_size + hash_size;
if (auth_cipher)
length += AEAD_EXPLICIT_DATA_SIZE;
break;
case CIPHER_BLOCK:
ret = _gnutls_rnd (GNUTLS_RND_NONCE, &rnd, 1);
if (ret < 0)
return gnutls_assert_val(ret);
/* make rnd a multiple of blocksize */
if (session->security_parameters.version == GNUTLS_SSL3 ||
random_pad == 0)
{
rnd = 0;
}
else
{
rnd = (rnd / blocksize) * blocksize;
/* added to avoid the case of pad calculated 0
* seen below for pad calculation.
*/
if (rnd > blocksize)
rnd -= blocksize;
}
length = data_size + hash_size;
*pad = (uint8_t) (blocksize - (length % blocksize)) + rnd;
length += *pad;
if (_gnutls_version_has_explicit_iv
(session->security_parameters.version))
length += blocksize; /* for the IV */
break;
default:
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
}
return length;
} | 0 | [
"CWE-310"
]
| gnutls | b495740f2ff66550ca9395b3fda3ea32c3acb185 | 7,745,663,360,408,685,000,000,000,000,000,000,000 | 55 | changes in packet parsing. |
int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
BIO *dcont, BIO *out, unsigned int flags)
{
int r;
BIO *cont;
if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_enveloped) {
CMSerr(CMS_F_CMS_DECRYPT, CMS_R_TYPE_NOT_ENVELOPED_DATA);
return 0;
}
if (!dcont && !check_content(cms))
return 0;
if (flags & CMS_DEBUG_DECRYPT)
cms->d.envelopedData->encryptedContentInfo->debug = 1;
else
cms->d.envelopedData->encryptedContentInfo->debug = 0;
if (!pk && !cert && !dcont && !out)
return 1;
if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert))
return 0;
cont = CMS_dataInit(cms, dcont);
if (!cont)
return 0;
r = cms_copy_content(out, cont, flags);
do_free_upto(cont, dcont);
return r;
} | 1 | [
"CWE-311",
"CWE-327"
]
| openssl | 08229ad838c50f644d7e928e2eef147b4308ad64 | 150,549,614,870,288,290,000,000,000,000,000,000,000 | 26 | Fix a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey
An attack is simple, if the first CMS_recipientInfo is valid but the
second CMS_recipientInfo is chosen ciphertext. If the second
recipientInfo decodes to PKCS #1 v1.5 form plaintext, the correct
encryption key will be replaced by garbage, and the message cannot be
decoded, but if the RSA decryption fails, the correct encryption key is
used and the recipient will not notice the attack.
As a work around for this potential attack the length of the decrypted
key must be equal to the cipher default key length, in case the
certifiate is not given and all recipientInfo are tried out.
The old behaviour can be re-enabled in the CMS code by setting the
CMS_DEBUG_DECRYPT flag.
Reviewed-by: Matt Caswell <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/9777)
(cherry picked from commit 5840ed0cd1e6487d247efbc1a04136a41d7b3a37) |
bool AuthorizationManagerImpl::shouldValidateAuthSchemaOnStartup() {
return _startupAuthSchemaValidation;
} | 0 | [
"CWE-613"
]
| mongo | e55d6e2292e5dbe2f97153251d8193d1cc89f5d7 | 6,312,202,995,297,344,000,000,000,000,000,000,000 | 3 | SERVER-38984 Validate unique User ID on UserCache hit |
static MagickBooleanType WritePTIFImage(const ImageInfo *image_info,
Image *image)
{
ExceptionInfo
*exception;
Image
*images,
*next,
*pyramid_image;
ImageInfo
*write_info;
MagickBooleanType
status;
PointInfo
resolution;
size_t
columns,
rows;
/*
Create pyramid-encoded TIFF image.
*/
exception=(&image->exception);
images=NewImageList();
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
{
Image
*clone_image;
clone_image=CloneImage(next,0,0,MagickFalse,exception);
if (clone_image == (Image *) NULL)
break;
clone_image->previous=NewImageList();
clone_image->next=NewImageList();
(void) SetImageProperty(clone_image,"tiff:subfiletype","none");
AppendImageToList(&images,clone_image);
columns=next->columns;
rows=next->rows;
resolution.x=next->x_resolution;
resolution.y=next->y_resolution;
while ((columns > 64) && (rows > 64))
{
columns/=2;
rows/=2;
resolution.x/=2.0;
resolution.y/=2.0;
pyramid_image=ResizeImage(next,columns,rows,image->filter,image->blur,
exception);
if (pyramid_image == (Image *) NULL)
break;
DestroyBlob(pyramid_image);
pyramid_image->blob=ReferenceBlob(next->blob);
pyramid_image->x_resolution=resolution.x;
pyramid_image->y_resolution=resolution.y;
(void) SetImageProperty(pyramid_image,"tiff:subfiletype","REDUCEDIMAGE");
AppendImageToList(&images,pyramid_image);
}
}
status=MagickFalse;
if (images != (Image *) NULL)
{
/*
Write pyramid-encoded TIFF image.
*/
images=GetFirstImageInList(images);
write_info=CloneImageInfo(image_info);
write_info->adjoin=MagickTrue;
status=WriteTIFFImage(write_info,images);
images=DestroyImageList(images);
write_info=DestroyImageInfo(write_info);
}
return(status);
} | 0 | [
"CWE-125"
]
| ImageMagick6 | d8d844c6f23f4d90d8fe893fe9225dd78fc1e6ef | 6,072,113,724,222,905,000,000,000,000,000,000,000 | 78 | https://github.com/ImageMagick/ImageMagick/issues/1532 |
static apr_status_t md_calc_md_list(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *base_server)
{
md_srv_conf_t *sc;
md_mod_conf_t *mc;
md_t *md, *omd;
const char *domain;
apr_status_t rv = APR_SUCCESS;
ap_listen_rec *lr;
apr_sockaddr_t *sa;
int i, j;
(void)plog;
sc = md_config_get(base_server);
mc = sc->mc;
mc->can_http = 0;
mc->can_https = 0;
for (lr = ap_listeners; lr; lr = lr->next) {
for (sa = lr->bind_addr; sa; sa = sa->next) {
if (sa->port == mc->local_80
&& (!lr->protocol || !strncmp("http", lr->protocol, 4))) {
mc->can_http = 1;
}
else if (sa->port == mc->local_443
&& (!lr->protocol || !strncmp("http", lr->protocol, 4))) {
mc->can_https = 1;
}
}
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, base_server, APLOGNO(10037)
"server seems%s reachable via http: (port 80->%d) "
"and%s reachable via https: (port 443->%d) ",
mc->can_http? "" : " not", mc->local_80,
mc->can_https? "" : " not", mc->local_443);
/* Complete the properties of the MDs, now that we have the complete, merged
* server configurations.
*/
for (i = 0; i < mc->mds->nelts; ++i) {
md = APR_ARRAY_IDX(mc->mds, i, md_t*);
md_merge_srv(md, sc, p);
/* Check that we have no overlap with the MDs already completed */
for (j = 0; j < i; ++j) {
omd = APR_ARRAY_IDX(mc->mds, j, md_t*);
if ((domain = md_common_name(md, omd)) != NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, base_server, APLOGNO(10038)
"two Managed Domains have an overlap in domain '%s'"
", first definition in %s(line %d), second in %s(line %d)",
domain, md->defn_name, md->defn_line_number,
omd->defn_name, omd->defn_line_number);
return APR_EINVAL;
}
}
/* Assign MD to the server_rec configs that it matches. Perform some
* last finishing touches on the MD. */
if (APR_SUCCESS != (rv = assign_to_servers(md, base_server, p, ptemp))) {
return rv;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, base_server, APLOGNO(10039)
"Completed MD[%s, CA=%s, Proto=%s, Agreement=%s, Drive=%d, renew=%ld]",
md->name, md->ca_url, md->ca_proto, md->ca_agreement,
md->drive_mode, (long)md->renew_window);
}
return rv;
} | 0 | [
"CWE-476"
]
| mod_md | e71001955809247b3aa4d269e1e0741b4fe0fc3d | 111,269,186,870,851,820,000,000,000,000,000,000,000 | 72 | v1.1.12, notifycmd improvements |
static int test_rand_add(void)
{
unsigned char rand_buf[256];
size_t rand_buflen;
memset(rand_buf, 0xCD, sizeof(rand_buf));
/* make sure it's instantiated */
RAND_seed(rand_buf, sizeof(rand_buf));
if (!TEST_true(RAND_status()))
return 0;
for ( rand_buflen = 256 ; rand_buflen > 0 ; --rand_buflen ) {
RAND_add(rand_buf, rand_buflen, 0.0);
if (!TEST_true(RAND_status()))
return 0;
}
return 1;
} | 0 | [
"CWE-330"
]
| openssl | 1b0fe00e2704b5e20334a16d3c9099d1ba2ef1be | 38,883,846,872,927,346,000,000,000,000,000,000,000 | 20 | drbg: ensure fork-safety without using a pthread_atfork handler
When the new OpenSSL CSPRNG was introduced in version 1.1.1,
it was announced in the release notes that it would be fork-safe,
which the old CSPRNG hadn't been.
The fork-safety was implemented using a fork count, which was
incremented by a pthread_atfork handler. Initially, this handler
was enabled by default. Unfortunately, the default behaviour
had to be changed for other reasons in commit b5319bdbd095, so
the new OpenSSL CSPRNG failed to keep its promise.
This commit restores the fork-safety using a different approach.
It replaces the fork count by a fork id, which coincides with
the process id on UNIX-like operating systems and is zero on other
operating systems. It is used to detect when an automatic reseed
after a fork is necessary.
To prevent a future regression, it also adds a test to verify that
the child reseeds after fork.
CVE-2019-1549
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/9802) |
trace(const unsigned int tracelevel)
{
curses_trace(tracelevel);
} | 0 | []
| ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | 36,873,953,145,356,195,000,000,000,000,000,000,000 | 4 | ncurses 6.2 - patch 20200531
+ correct configure version-check/warnng for g++ to allow for 10.x
+ re-enable "bel" in konsole-base (report by Nia Huang)
+ add linux-s entry (patch by Alexandre Montaron).
+ drop long-obsolete convert_configure.pl
+ add test/test_parm.c, for checking tparm changes.
+ improve parameter-checking for tparm, adding function _nc_tiparm() to
handle the most-used case, which accepts only numeric parameters
(report/testcase by "puppet-meteor").
+ use a more conservative estimate of the buffer-size in lib_tparm.c's
save_text() and save_number(), in case the sprintf() function
passes-through unexpected characters from a format specifier
(report/testcase by "puppet-meteor").
+ add a check for end-of-string in cvtchar to handle a malformed
string in infotocap (report/testcase by "puppet-meteor"). |
static int oidc_request_post_preserved_restore(request_rec *r,
const char *original_url) {
oidc_debug(r, "enter: original_url=%s", original_url);
const char *method = "postOnLoad";
const char *script =
apr_psprintf(r->pool,
" <script type=\"text/javascript\">\n"
" function str_decode(string) {\n"
" try {\n"
" result = decodeURIComponent(string);\n"
" } catch (e) {\n"
" result = unescape(string);\n"
" }\n"
" return result;\n"
" }\n"
" function %s() {\n"
" var mod_auth_openidc_preserve_post_params = JSON.parse(sessionStorage.getItem('mod_auth_openidc_preserve_post_params'));\n"
" sessionStorage.removeItem('mod_auth_openidc_preserve_post_params');\n"
" for (var key in mod_auth_openidc_preserve_post_params) {\n"
" var input = document.createElement(\"input\");\n"
" input.name = str_decode(key);\n"
" input.value = str_decode(mod_auth_openidc_preserve_post_params[key]);\n"
" input.type = \"hidden\";\n"
" document.forms[0].appendChild(input);\n"
" }\n"
" document.forms[0].action = \"%s\";\n"
" document.forms[0].submit();\n"
" }\n"
" </script>\n", method, original_url);
const char *body = " <p>Restoring...</p>\n"
" <form method=\"post\"></form>\n";
return oidc_util_html_send(r, "Restoring...", script, method, body,
OK);
} | 1 | [
"CWE-79"
]
| mod_auth_openidc | 55ea0a085290cd2c8cdfdd960a230cbc38ba8b56 | 136,991,931,915,956,620,000,000,000,000,000,000,000 | 38 | Add a function to escape Javascript characters |
void compareHeaders(Headers&& headers, const ExpectedHeaders& expected_headers) {
headers.remove(Envoy::Http::LowerCaseString{"content-length"});
headers.remove(Envoy::Http::LowerCaseString{"date"});
if (!routerSuppressEnvoyHeaders()) {
headers.remove(Envoy::Http::LowerCaseString{"x-envoy-expected-rq-timeout-ms"});
headers.remove(Envoy::Http::LowerCaseString{"x-envoy-upstream-service-time"});
}
headers.remove(Envoy::Http::LowerCaseString{"x-forwarded-proto"});
headers.remove(Envoy::Http::LowerCaseString{"x-request-id"});
headers.remove(Envoy::Http::LowerCaseString{"x-envoy-internal"});
EXPECT_THAT(&headers, HeaderMapEqualIgnoreOrder(&expected_headers));
} | 0 | [
"CWE-22"
]
| envoy | 5333b928d8bcffa26ab19bf018369a835f697585 | 123,144,836,467,198,480,000,000,000,000,000,000,000 | 13 | Implement handling of escaped slash characters in URL path
Fixes: CVE-2021-29492
Signed-off-by: Yan Avlasov <[email protected]> |
R_API int r_bin_load_io(RBin *bin, int fd, ut64 baseaddr, ut64 loadaddr, int xtr_idx) {
return r_bin_load_io_at_offset_as (bin, fd, baseaddr, loadaddr, xtr_idx, 0, NULL);
} | 0 | [
"CWE-125"
]
| radare2 | d31c4d3cbdbe01ea3ded16a584de94149ecd31d9 | 317,046,946,856,672,870,000,000,000,000,000,000,000 | 3 | Fix #8748 - Fix oobread on string search |
gst_asf_demux_is_unknown_stream (GstASFDemux * demux, guint stream_num)
{
return g_slist_find (demux->other_streams,
GINT_TO_POINTER (stream_num)) == NULL;
} | 0 | [
"CWE-125",
"CWE-787"
]
| gst-plugins-ugly | d21017b52a585f145e8d62781bcc1c5fefc7ee37 | 201,357,953,129,331,800,000,000,000,000,000,000,000 | 5 | asfdemux: Check that we have enough data available before parsing bool/uint extended content descriptors
https://bugzilla.gnome.org/show_bug.cgi?id=777955 |
NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
{
if (SP_PARM != 0) {
UpdateAttrs(SP_PARM, normal);
#if NCURSES_EXT_FUNCS
if (SP_PARM->_coloron
&& !SP_PARM->_default_color) {
static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
SP_PARM->_default_color = TRUE;
NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
-1,
0,
FALSE,
NCURSES_SP_NAME(_nc_outch));
SP_PARM->_default_color = FALSE;
TINFO_MVCUR(NCURSES_SP_ARGx
SP_PARM->_cursrow,
SP_PARM->_curscol,
screen_lines(SP_PARM) - 1,
0);
ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
}
#endif
if (SP_PARM->_color_defs) {
NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
}
}
} | 0 | []
| ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | 62,304,088,349,878,280,000,000,000,000,000,000,000 | 31 | ncurses 6.2 - patch 20200531
+ correct configure version-check/warnng for g++ to allow for 10.x
+ re-enable "bel" in konsole-base (report by Nia Huang)
+ add linux-s entry (patch by Alexandre Montaron).
+ drop long-obsolete convert_configure.pl
+ add test/test_parm.c, for checking tparm changes.
+ improve parameter-checking for tparm, adding function _nc_tiparm() to
handle the most-used case, which accepts only numeric parameters
(report/testcase by "puppet-meteor").
+ use a more conservative estimate of the buffer-size in lib_tparm.c's
save_text() and save_number(), in case the sprintf() function
passes-through unexpected characters from a format specifier
(report/testcase by "puppet-meteor").
+ add a check for end-of-string in cvtchar to handle a malformed
string in infotocap (report/testcase by "puppet-meteor"). |
void Field_num::make_field(Send_field *field)
{
Field::make_field(field);
field->decimals= dec;
} | 0 | [
"CWE-120"
]
| server | eca207c46293bc72dd8d0d5622153fab4d3fccf1 | 241,131,034,949,156,370,000,000,000,000,000,000,000 | 5 | MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size.
Precision should be kept below DECIMAL_MAX_SCALE for computations.
It can be bigger in Item_decimal. I'd fix this too but it changes the
existing behaviour so problemmatic to ix. |
void qxl_render_resize(PCIQXLDevice *qxl)
{
QXLSurfaceCreate *sc = &qxl->guest_primary.surface;
qxl->guest_primary.qxl_stride = sc->stride;
qxl->guest_primary.abs_stride = abs(sc->stride);
qxl->guest_primary.resized++;
switch (sc->format) {
case SPICE_SURFACE_FMT_16_555:
qxl->guest_primary.bytes_pp = 2;
qxl->guest_primary.bits_pp = 15;
break;
case SPICE_SURFACE_FMT_16_565:
qxl->guest_primary.bytes_pp = 2;
qxl->guest_primary.bits_pp = 16;
break;
case SPICE_SURFACE_FMT_32_xRGB:
case SPICE_SURFACE_FMT_32_ARGB:
qxl->guest_primary.bytes_pp = 4;
qxl->guest_primary.bits_pp = 32;
break;
default:
fprintf(stderr, "%s: unhandled format: %x\n", __func__,
qxl->guest_primary.surface.format);
qxl->guest_primary.bytes_pp = 4;
qxl->guest_primary.bits_pp = 32;
break;
}
} | 0 | []
| qemu | 9569f5cb5b4bffa9d3ebc8ba7da1e03830a9a895 | 324,993,051,255,012,500,000,000,000,000,000,000,000 | 29 | display/qxl-render: fix race condition in qxl_cursor (CVE-2021-4207)
Avoid fetching 'width' and 'height' a second time to prevent possible
race condition. Refer to security advisory
https://starlabs.sg/advisories/22-4207/ for more information.
Fixes: CVE-2021-4207
Signed-off-by: Mauro Matteo Cascella <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]> |
static int StreamTcpTest27(void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
StreamTcpThread stt;
uint8_t payload[4];
TCPHdr tcph;
int ret = 0;
PacketQueue pq;
memset(&pq,0,sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
memset (&f, 0, sizeof(Flow));
memset(&tv, 0, sizeof (ThreadVars));
memset(&stt, 0, sizeof (StreamTcpThread));
memset(&tcph, 0, sizeof (TCPHdr));
FLOW_INITIALIZE(&f);
p->flow = &f;
tcph.th_win = htons(5480);
tcph.th_flags = TH_SYN | TH_CWR | TH_ECN;
p->tcph = &tcph;
p->flowflags = FLOW_PKT_TOSERVER;
StreamTcpUTInit(&stt.ra_ctx);
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1)
goto end;
p->tcph->th_ack = htonl(1);
p->tcph->th_flags = TH_SYN | TH_ACK;
p->flowflags = FLOW_PKT_TOCLIENT;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
p->tcph->th_ack = htonl(1);
p->tcph->th_seq = htonl(1);
p->tcph->th_flags = TH_ACK;
p->flowflags = FLOW_PKT_TOSERVER;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
p->tcph->th_ack = htonl(1);
p->tcph->th_seq = htonl(2);
p->tcph->th_flags = TH_PUSH | TH_ACK;
p->flowflags = FLOW_PKT_TOSERVER;
StreamTcpCreateTestPacket(payload, 0x41, 3, 4); /*AAA*/
p->payload = payload;
p->payload_len = 3;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
p->flowflags = FLOW_PKT_TOCLIENT;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
p->tcph->th_ack = htonl(1);
p->tcph->th_seq = htonl(6);
p->tcph->th_flags = TH_PUSH | TH_ACK;
p->flowflags = FLOW_PKT_TOSERVER;
StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/
p->payload = payload;
p->payload_len = 3;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
p->flowflags = FLOW_PKT_TOCLIENT;
if (StreamTcpPacket(&tv, p, &stt, &pq) == -1 || (TcpSession *)p->flow->protoctx == NULL)
goto end;
StreamTcpSessionClear(p->flow->protoctx);
ret = 1;
end:
SCFree(p);
FLOW_DESTROY(&f);
StreamTcpUTDeinit(stt.ra_ctx);
return ret;
} | 0 | []
| suricata | 843d0b7a10bb45627f94764a6c5d468a24143345 | 307,338,218,255,969,050,000,000,000,000,000,000,000 | 88 | stream: support RST getting lost/ignored
In case of a valid RST on a SYN, the state is switched to 'TCP_CLOSED'.
However, the target of the RST may not have received it, or may not
have accepted it. Also, the RST may have been injected, so the supposed
sender may not actually be aware of the RST that was sent in it's name.
In this case the previous behavior was to switch the state to CLOSED and
accept no further TCP updates or stream reassembly.
This patch changes this. It still switches the state to CLOSED, as this
is by far the most likely to be correct. However, it will reconsider
the state if the receiver continues to talk.
To do this on each state change the previous state will be recorded in
TcpSession::pstate. If a non-RST packet is received after a RST, this
TcpSession::pstate is used to try to continue the conversation.
If the (supposed) sender of the RST is also continueing the conversation
as normal, it's highly likely it didn't send the RST. In this case
a stream event is generated.
Ticket: #2501
Reported-By: Kirill Shipulin |
void Item_decimal_typecast::print(String *str, enum_query_type query_type)
{
char len_buf[20*3 + 1];
char *end;
uint precision= my_decimal_length_to_precision(max_length, decimals,
unsigned_flag);
str->append(STRING_WITH_LEN("cast("));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" as decimal("));
end=int10_to_str(precision, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(',');
end=int10_to_str(decimals, len_buf,10);
str->append(len_buf, (uint32) (end - len_buf));
str->append(')');
str->append(')');
} | 0 | [
"CWE-120"
]
| server | eca207c46293bc72dd8d0d5622153fab4d3fccf1 | 52,858,204,405,681,730,000,000,000,000,000,000,000 | 22 | MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size.
Precision should be kept below DECIMAL_MAX_SCALE for computations.
It can be bigger in Item_decimal. I'd fix this too but it changes the
existing behaviour so problemmatic to ix. |
inc_tx_bcast_or_mcast_count(E1000State *s, const unsigned char *arr)
{
if (!memcmp(arr, bcast, sizeof bcast)) {
e1000x_inc_reg_if_not_full(s->mac_reg, BPTC);
} else if (arr[0] & 1) {
e1000x_inc_reg_if_not_full(s->mac_reg, MPTC);
}
} | 0 | [
"CWE-835"
]
| qemu | 1caff0340f49c93d535c6558a5138d20d475315c | 77,162,720,200,057,210,000,000,000,000,000,000,000 | 8 | e1000: switch to use qemu_receive_packet() for loopback
This patch switches to use qemu_receive_packet() which can detect
reentrancy and return early.
This is intended to address CVE-2021-3416.
Cc: Prasad J Pandit <[email protected]>
Cc: [email protected]
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Jason Wang <[email protected]> |
static bool nic_exists(char *nic)
{
char path[MAXPATHLEN];
int ret;
struct stat sb;
if (strcmp(nic, "none") == 0)
return true;
ret = snprintf(path, MAXPATHLEN, "/sys/class/net/%s", nic);
if (ret < 0 || ret >= MAXPATHLEN) // should never happen!
return false;
ret = stat(path, &sb);
if (ret != 0)
return false;
return true;
} | 0 | [
"CWE-284",
"CWE-862"
]
| lxc | 16af238036a5464ae8f2420ed3af214f0de875f9 | 61,232,645,080,950,710,000,000,000,000,000,000,000 | 16 | CVE-2017-5985: Ensure target netns is caller-owned
Before this commit, lxc-user-nic could potentially have been tricked into
operating on a network namespace over which the caller did not hold privilege.
This commit ensures that the caller is privileged over the network namespace by
temporarily dropping privilege.
Launchpad: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1654676
Reported-by: Jann Horn <[email protected]>
Signed-off-by: Christian Brauner <[email protected]> |
static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
struct sockaddr *uaddr, int addr_len) {
struct net *net = sock_net(sk);
if (sk->sk_family == AF_INET) {
struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
int chk_addr_ret;
if (addr_len < sizeof(*addr))
return -EINVAL;
if (addr->sin_family != AF_INET &&
!(addr->sin_family == AF_UNSPEC &&
addr->sin_addr.s_addr == htonl(INADDR_ANY)))
return -EAFNOSUPPORT;
pr_debug("ping_check_bind_addr(sk=%p,addr=%pI4,port=%d)\n",
sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port));
chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
if (addr->sin_addr.s_addr == htonl(INADDR_ANY))
chk_addr_ret = RTN_LOCAL;
if ((net->ipv4.sysctl_ip_nonlocal_bind == 0 &&
isk->freebind == 0 && isk->transparent == 0 &&
chk_addr_ret != RTN_LOCAL) ||
chk_addr_ret == RTN_MULTICAST ||
chk_addr_ret == RTN_BROADCAST)
return -EADDRNOTAVAIL;
#if IS_ENABLED(CONFIG_IPV6)
} else if (sk->sk_family == AF_INET6) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr;
int addr_type, scoped, has_addr;
struct net_device *dev = NULL;
if (addr_len < sizeof(*addr))
return -EINVAL;
if (addr->sin6_family != AF_INET6)
return -EAFNOSUPPORT;
pr_debug("ping_check_bind_addr(sk=%p,addr=%pI6c,port=%d)\n",
sk, addr->sin6_addr.s6_addr, ntohs(addr->sin6_port));
addr_type = ipv6_addr_type(&addr->sin6_addr);
scoped = __ipv6_addr_needs_scope_id(addr_type);
if ((addr_type != IPV6_ADDR_ANY &&
!(addr_type & IPV6_ADDR_UNICAST)) ||
(scoped && !addr->sin6_scope_id))
return -EINVAL;
rcu_read_lock();
if (addr->sin6_scope_id) {
dev = dev_get_by_index_rcu(net, addr->sin6_scope_id);
if (!dev) {
rcu_read_unlock();
return -ENODEV;
}
}
has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
scoped);
rcu_read_unlock();
if (!(net->ipv6.sysctl.ip_nonlocal_bind ||
isk->freebind || isk->transparent || has_addr ||
addr_type == IPV6_ADDR_ANY))
return -EADDRNOTAVAIL;
if (scoped)
sk->sk_bound_dev_if = addr->sin6_scope_id;
#endif
} else {
return -EAFNOSUPPORT;
}
return 0;
} | 0 | [
"CWE-284"
]
| linux | 0eab121ef8750a5c8637d51534d5e9143fb0633f | 18,565,236,689,340,307,000,000,000,000,000,000,000 | 77 | net: ping: check minimum size on ICMP header length
Prior to commit c0371da6047a ("put iov_iter into msghdr") in v3.19, there
was no check that the iovec contained enough bytes for an ICMP header,
and the read loop would walk across neighboring stack contents. Since the
iov_iter conversion, bad arguments are noticed, but the returned error is
EFAULT. Returning EINVAL is a clearer error and also solves the problem
prior to v3.19.
This was found using trinity with KASAN on v3.18:
BUG: KASAN: stack-out-of-bounds in memcpy_fromiovec+0x60/0x114 at addr ffffffc071077da0
Read of size 8 by task trinity-c2/9623
page:ffffffbe034b9a08 count:0 mapcount:0 mapping: (null) index:0x0
flags: 0x0()
page dumped because: kasan: bad access detected
CPU: 0 PID: 9623 Comm: trinity-c2 Tainted: G BU 3.18.0-dirty #15
Hardware name: Google Tegra210 Smaug Rev 1,3+ (DT)
Call trace:
[<ffffffc000209c98>] dump_backtrace+0x0/0x1ac arch/arm64/kernel/traps.c:90
[<ffffffc000209e54>] show_stack+0x10/0x1c arch/arm64/kernel/traps.c:171
[< inline >] __dump_stack lib/dump_stack.c:15
[<ffffffc000f18dc4>] dump_stack+0x7c/0xd0 lib/dump_stack.c:50
[< inline >] print_address_description mm/kasan/report.c:147
[< inline >] kasan_report_error mm/kasan/report.c:236
[<ffffffc000373dcc>] kasan_report+0x380/0x4b8 mm/kasan/report.c:259
[< inline >] check_memory_region mm/kasan/kasan.c:264
[<ffffffc00037352c>] __asan_load8+0x20/0x70 mm/kasan/kasan.c:507
[<ffffffc0005b9624>] memcpy_fromiovec+0x5c/0x114 lib/iovec.c:15
[< inline >] memcpy_from_msg include/linux/skbuff.h:2667
[<ffffffc000ddeba0>] ping_common_sendmsg+0x50/0x108 net/ipv4/ping.c:674
[<ffffffc000dded30>] ping_v4_sendmsg+0xd8/0x698 net/ipv4/ping.c:714
[<ffffffc000dc91dc>] inet_sendmsg+0xe0/0x12c net/ipv4/af_inet.c:749
[< inline >] __sock_sendmsg_nosec net/socket.c:624
[< inline >] __sock_sendmsg net/socket.c:632
[<ffffffc000cab61c>] sock_sendmsg+0x124/0x164 net/socket.c:643
[< inline >] SYSC_sendto net/socket.c:1797
[<ffffffc000cad270>] SyS_sendto+0x178/0x1d8 net/socket.c:1761
CVE-2016-8399
Reported-by: Qidan He <[email protected]>
Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
PJ_DEF(pj_status_t) pjsua_create(void)
{
pj_status_t status;
/* Init pjsua data */
init_data();
/* Set default logging settings */
pjsua_logging_config_default(&pjsua_var.log_cfg);
/* Init PJLIB: */
status = pj_init();
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
pj_log_push_indent();
/* Init random seed */
init_random_seed();
/* Init PJLIB-UTIL: */
status = pjlib_util_init();
if (status != PJ_SUCCESS) {
pj_log_pop_indent();
pjsua_perror(THIS_FILE, "Failed in initializing pjlib-util", status);
pj_shutdown();
return status;
}
/* Init PJNATH */
status = pjnath_init();
if (status != PJ_SUCCESS) {
pj_log_pop_indent();
pjsua_perror(THIS_FILE, "Failed in initializing pjnath", status);
pj_shutdown();
return status;
}
/* Set default sound device ID */
pjsua_var.cap_dev = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV;
pjsua_var.play_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV;
/* Set default video device ID */
pjsua_var.vcap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
pjsua_var.vrdr_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV;
/* Init caching pool. */
pj_caching_pool_init(&pjsua_var.cp, NULL, 0);
/* Create memory pools for application and internal use. */
pjsua_var.pool = pjsua_pool_create("pjsua", PJSUA_POOL_LEN, PJSUA_POOL_INC);
pjsua_var.timer_pool = pjsua_pool_create("pjsua_timer", 500, 500);
if (pjsua_var.pool == NULL || pjsua_var.timer_pool == NULL) {
pj_log_pop_indent();
status = PJ_ENOMEM;
pjsua_perror(THIS_FILE, "Unable to create pjsua/timer pool", status);
pj_shutdown();
return status;
}
/* Create mutex */
status = pj_mutex_create_recursive(pjsua_var.pool, "pjsua",
&pjsua_var.mutex);
if (status != PJ_SUCCESS) {
pj_log_pop_indent();
pjsua_perror(THIS_FILE, "Unable to create mutex", status);
pjsua_destroy();
return status;
}
/* Must create SIP endpoint to initialize SIP parser. The parser
* is needed for example when application needs to call pjsua_verify_url().
*/
status = pjsip_endpt_create(&pjsua_var.cp.factory,
pj_gethostname()->ptr,
&pjsua_var.endpt);
if (status != PJ_SUCCESS) {
pj_log_pop_indent();
pjsua_perror(THIS_FILE, "Unable to create endpoint", status);
pjsua_destroy();
return status;
}
/* Init timer entry and event list */
pj_list_init(&pjsua_var.active_timer_list);
pj_list_init(&pjsua_var.timer_list);
pj_list_init(&pjsua_var.event_list);
/* Create timer mutex */
status = pj_mutex_create_recursive(pjsua_var.pool, "pjsua_timer",
&pjsua_var.timer_mutex);
if (status != PJ_SUCCESS) {
pj_log_pop_indent();
pjsua_perror(THIS_FILE, "Unable to create mutex", status);
pjsua_destroy();
return status;
}
pjsua_set_state(PJSUA_STATE_CREATED);
pj_log_pop_indent();
return PJ_SUCCESS;
} | 0 | [
"CWE-120",
"CWE-787"
]
| pjproject | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | 37,217,045,998,828,153,000,000,000,000,000,000,000 | 101 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. |
int unregister_ftrace_command(struct ftrace_func_command *cmd)
{
struct ftrace_func_command *p, *n;
int ret = -ENODEV;
mutex_lock(&ftrace_cmd_mutex);
list_for_each_entry_safe(p, n, &ftrace_commands, list) {
if (strcmp(cmd->name, p->name) == 0) {
ret = 0;
list_del_init(&p->list);
goto out_unlock;
}
}
out_unlock:
mutex_unlock(&ftrace_cmd_mutex);
return ret;
} | 0 | [
"CWE-703"
]
| linux | 6a76f8c0ab19f215af2a3442870eeb5f0e81998d | 288,277,876,442,328,950,000,000,000,000,000,000,000 | 18 | tracing: Fix possible NULL pointer dereferences
Currently set_ftrace_pid and set_graph_function files use seq_lseek
for their fops. However seq_open() is called only for FMODE_READ in
the fops->open() so that if an user tries to seek one of those file
when she open it for writing, it sees NULL seq_file and then panic.
It can be easily reproduced with following command:
$ cd /sys/kernel/debug/tracing
$ echo 1234 | sudo tee -a set_ftrace_pid
In this example, GNU coreutils' tee opens the file with fopen(, "a")
and then the fopen() internally calls lseek().
Link: http://lkml.kernel.org/r/[email protected]
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: [email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]> |
unsigned char *aligned_alloc(size_t dsize) {
unsigned char*data = (unsigned char*) custom_malloc( dsize + 16);
if (data) {
size_t rem = (size_t)(data - 0) & 0xf;
if (rem) {
data += rem;
data[-1] = rem;
} else {
data += 0x10;
data[-1] = 0x10;
}
}
return data;
} | 0 | [
"CWE-1187"
]
| lepton | 82167c144a322cc956da45407f6dce8d4303d346 | 87,992,984,943,559,350,000,000,000,000,000,000,000 | 14 | fix #87 : always check that threads_required set up the appropriate number of threads---fire off nop functions on unused threads for consistency |
TEST(IndexBoundsBuilderTest, TranslateEqualityToStringWithMockCollator) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
auto testIndex = buildSimpleIndexEntry();
testIndex.collator = &collator;
BSONObj obj = BSON("a"
<< "foo");
auto expr = parseMatchExpression(obj);
BSONElement elt = obj.firstElement();
OrderedIntervalList oil;
IndexBoundsBuilder::BoundsTightness tightness;
IndexBoundsBuilder::translate(expr.get(), elt, testIndex, &oil, &tightness);
ASSERT_EQUALS(oil.name, "a");
ASSERT_EQUALS(oil.intervals.size(), 1U);
ASSERT_EQUALS(
Interval::INTERVAL_EQUALS,
oil.intervals[0].compare(Interval(fromjson("{'': 'oof', '': 'oof'}"), true, true)));
ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT);
} | 0 | [
"CWE-754"
]
| mongo | f8f55e1825ee5c7bdb3208fc7c5b54321d172732 | 153,908,319,210,030,020,000,000,000,000,000,000,000 | 21 | SERVER-44377 generate correct plan for indexed inequalities to null |
TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
thr_lock_type lock_type, uint flags,
Prelocking_strategy *prelocking_strategy)
{
TABLE_LIST *save_next_global;
DBUG_ENTER("open_n_lock_single_table");
/* Remember old 'next' pointer. */
save_next_global= table_l->next_global;
/* Break list. */
table_l->next_global= NULL;
/* Set requested lock type. */
table_l->lock_type= lock_type;
/* Allow to open real tables only. */
table_l->required_type= TABLE_TYPE_NORMAL;
/* Open the table. */
if (open_and_lock_tables(thd, table_l, FALSE, flags,
prelocking_strategy))
table_l->table= NULL; /* Just to be sure. */
/* Restore list. */
table_l->next_global= save_next_global;
DBUG_RETURN(table_l->table);
} | 0 | [
"CWE-416"
]
| server | c02ebf3510850ba78a106be9974c94c3b97d8585 | 262,891,848,794,594,100,000,000,000,000,000,000,000 | 27 | 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. |
void RGWBulkUploadOp::pre_exec()
{
rgw_bucket_object_pre_exec(s);
} | 0 | [
"CWE-770"
]
| ceph | ab29bed2fc9f961fe895de1086a8208e21ddaddc | 43,570,266,816,238,770,000,000,000,000,000,000,000 | 4 | rgw: fix issues with 'enforce bounds' patch
The patch to enforce bounds on max-keys/max-uploads/max-parts had a few
issues that would prevent us from compiling it. Instead of changing the
code provided by the submitter, we're addressing them in a separate
commit to maintain the DCO.
Signed-off-by: Joao Eduardo Luis <[email protected]>
Signed-off-by: Abhishek Lekshmanan <[email protected]>
(cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a)
mimic specific fixes:
As the largeish change from master g_conf() isn't in mimic yet, use the g_conf
global structure, also make rgw_op use the value from req_info ceph context as
we do for all the requests |
libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host,
int port, int *bound_port, int queue_maxsize)
{
LIBSSH2_LISTENER *ptr;
if(!session)
return NULL;
BLOCK_ADJUST_ERRNO(ptr, session,
channel_forward_listen(session, host, port, bound_port,
queue_maxsize));
return ptr;
} | 0 | [
"CWE-787"
]
| libssh2 | dc109a7f518757741590bb993c0c8412928ccec2 | 251,795,606,419,780,900,000,000,000,000,000,000,000 | 13 | Security fixes (#315)
* Bounds checks
Fixes for CVEs
https://www.libssh2.org/CVE-2019-3863.html
https://www.libssh2.org/CVE-2019-3856.html
* Packet length bounds check
CVE
https://www.libssh2.org/CVE-2019-3855.html
* Response length check
CVE
https://www.libssh2.org/CVE-2019-3859.html
* Bounds check
CVE
https://www.libssh2.org/CVE-2019-3857.html
* Bounds checking
CVE
https://www.libssh2.org/CVE-2019-3859.html
and additional data validation
* Check bounds before reading into buffers
* Bounds checking
CVE
https://www.libssh2.org/CVE-2019-3859.html
* declare SIZE_MAX and UINT_MAX if needed |
QPDF_Stream::filterable(std::vector<std::string>& filters,
bool& specialized_compression,
bool& lossy_compression,
int& predictor, int& columns,
int& colors, int& bits_per_component,
bool& early_code_change)
{
if (filter_abbreviations.empty())
{
// The PDF specification provides these filter abbreviations
// for use in inline images, but according to table H.1 in the
// pre-ISO versions of the PDF specification, Adobe Reader
// also accepts them for stream filters.
filter_abbreviations["/AHx"] = "/ASCIIHexDecode";
filter_abbreviations["/A85"] = "/ASCII85Decode";
filter_abbreviations["/LZW"] = "/LZWDecode";
filter_abbreviations["/Fl"] = "/FlateDecode";
filter_abbreviations["/RL"] = "/RunLengthDecode";
filter_abbreviations["/CCF"] = "/CCITTFaxDecode";
filter_abbreviations["/DCT"] = "/DCTDecode";
}
// Check filters
QPDFObjectHandle filter_obj = this->stream_dict.getKey("/Filter");
bool filters_okay = true;
if (filter_obj.isNull())
{
// No filters
}
else if (filter_obj.isName())
{
// One filter
filters.push_back(filter_obj.getName());
}
else if (filter_obj.isArray())
{
// Potentially multiple filters
int n = filter_obj.getArrayNItems();
for (int i = 0; i < n; ++i)
{
QPDFObjectHandle item = filter_obj.getArrayItem(i);
if (item.isName())
{
filters.push_back(item.getName());
}
else
{
filters_okay = false;
}
}
}
else
{
filters_okay = false;
}
if (! filters_okay)
{
QTC::TC("qpdf", "QPDF_Stream invalid filter");
warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
"", this->offset,
"stream filter type is not name or array"));
return false;
}
bool filterable = true;
for (std::vector<std::string>::iterator iter = filters.begin();
iter != filters.end(); ++iter)
{
std::string& filter = *iter;
if (filter_abbreviations.count(filter))
{
QTC::TC("qpdf", "QPDF_Stream expand filter abbreviation");
filter = filter_abbreviations[filter];
}
if (filter == "/RunLengthDecode")
{
specialized_compression = true;
}
else if (filter == "/DCTDecode")
{
specialized_compression = true;
lossy_compression = true;
}
else if (! ((filter == "/Crypt") ||
(filter == "/FlateDecode") ||
(filter == "/LZWDecode") ||
(filter == "/ASCII85Decode") ||
(filter == "/ASCIIHexDecode")))
{
filterable = false;
}
}
if (! filterable)
{
return false;
}
// `filters' now contains a list of filters to be applied in
// order. See which ones we can support.
// Initialize values to their defaults as per the PDF spec
predictor = 1;
columns = 0;
colors = 1;
bits_per_component = 8;
early_code_change = true;
// See if we can support any decode parameters that are specified.
QPDFObjectHandle decode_obj = this->stream_dict.getKey("/DecodeParms");
std::vector<QPDFObjectHandle> decode_parms;
if (decode_obj.isArray() && (decode_obj.getArrayNItems() == 0))
{
decode_obj = QPDFObjectHandle::newNull();
}
if (decode_obj.isArray())
{
for (int i = 0; i < decode_obj.getArrayNItems(); ++i)
{
decode_parms.push_back(decode_obj.getArrayItem(i));
}
}
else
{
for (unsigned int i = 0; i < filters.size(); ++i)
{
decode_parms.push_back(decode_obj);
}
}
// Ignore /DecodeParms entirely if /Filters is empty. At least
// one case of a file whose /DecodeParms was [ << >> ] when
// /Filters was empty has been seen in the wild.
if ((filters.size() != 0) && (decode_parms.size() != filters.size()))
{
warn(QPDFExc(qpdf_e_damaged_pdf, qpdf->getFilename(),
"", this->offset,
"stream /DecodeParms length is"
" inconsistent with filters"));
filterable = false;
}
if (! filterable)
{
return false;
}
for (unsigned int i = 0; i < filters.size(); ++i)
{
QPDFObjectHandle decode_item = decode_parms.at(i);
if (decode_item.isNull())
{
// okay
}
else if (decode_item.isDictionary())
{
if (! understandDecodeParams(
filters.at(i), decode_item,
predictor, columns, colors, bits_per_component,
early_code_change))
{
filterable = false;
}
}
else
{
filterable = false;
}
}
if ((predictor > 1) && (columns == 0))
{
// invalid
filterable = false;
}
if (! filterable)
{
return false;
}
return filterable;
} | 0 | [
"CWE-787"
]
| qpdf | d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e | 76,734,067,942,244,930,000,000,000,000,000,000,000 | 190 | Fix sign and conversion warnings (major)
This makes all integer type conversions that have potential data loss
explicit with calls that do range checks and raise an exception. After
this commit, qpdf builds with no warnings when -Wsign-conversion
-Wconversion is used with gcc or clang or when -W3 -Wd4800 is used
with MSVC. This significantly reduces the likelihood of potential
crashes from bogus integer values.
There are some parts of the code that take int when they should take
size_t or an offset. Such places would make qpdf not support files
with more than 2^31 of something that usually wouldn't be so large. In
the event that such a file shows up and is valid, at least qpdf would
raise an error in the right spot so the issue could be legitimately
addressed rather than failing in some weird way because of a silent
overflow condition. |
int cil_gen_senscat(struct cil_db *db, struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
{
enum cil_syntax syntax[] = {
CIL_SYN_STRING,
CIL_SYN_STRING,
CIL_SYN_STRING | CIL_SYN_LIST,
CIL_SYN_END
};
int syntax_len = sizeof(syntax)/sizeof(*syntax);
struct cil_senscat *senscat = NULL;
int rc = SEPOL_ERR;
if (db == NULL || parse_current == NULL || ast_node == NULL) {
goto exit;
}
rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
if (rc != SEPOL_OK) {
goto exit;
}
cil_senscat_init(&senscat);
senscat->sens_str = parse_current->next->data;
rc = cil_fill_cats(parse_current->next->next, &senscat->cats);
if (rc != SEPOL_OK) {
goto exit;
}
ast_node->data = senscat;
ast_node->flavor = CIL_SENSCAT;
return SEPOL_OK;
exit:
cil_tree_log(parse_current, CIL_ERR, "Bad sensitivitycategory declaration");
cil_destroy_senscat(senscat);
return rc;
} | 0 | [
"CWE-125"
]
| selinux | 340f0eb7f3673e8aacaf0a96cbfcd4d12a405521 | 301,500,892,786,301,650,000,000,000,000,000,000,000 | 40 | libsepol/cil: Check for statements not allowed in optional blocks
While there are some checks for invalid statements in an optional
block when resolving the AST, there are no checks when building the
AST.
OSS-Fuzz found the following policy which caused a null dereference
in cil_tree_get_next_path().
(blockinherit b3)
(sid SID)
(sidorder(SID))
(optional o
(ibpkeycon :(1 0)s)
(block b3
(filecon""block())
(filecon""block())))
The problem is that the blockinherit copies block b3 before
the optional block is disabled. When the optional is disabled,
block b3 is deleted along with everything else in the optional.
Later, when filecon statements with the same path are found an
error message is produced and in trying to find out where the block
was copied from, the reference to the deleted block is used. The
error handling code assumes (rightly) that if something was copied
from a block then that block should still exist.
It is clear that in-statements, blocks, and macros cannot be in an
optional, because that allows nodes to be copied from the optional
block to somewhere outside even though the optional could be disabled
later. When optionals are disabled the AST is reset and the
resolution is restarted at the point of resolving macro calls, so
anything resolved before macro calls will never be re-resolved.
This includes tunableifs, in-statements, blockinherits,
blockabstracts, and macro definitions. Tunable declarations also
cannot be in an optional block because they are needed to resolve
tunableifs. It should be fine to allow blockinherit statements in
an optional, because that is copying nodes from outside the optional
to the optional and if the optional is later disabled, everything
will be deleted anyway.
Check and quit with an error if a tunable declaration, in-statement,
block, blockabstract, or macro definition is found within an
optional when either building or resolving the AST.
Signed-off-by: James Carter <[email protected]> |
MaybeLocal<Value> GetCipherStandardName(
Environment* env,
const SSLPointer& ssl) {
return GetCipherStandardName(env, SSL_get_current_cipher(ssl.get()));
} | 0 | [
"CWE-295"
]
| node | 466e5415a2b7b3574ab5403acb87e89a94a980d1 | 256,745,292,457,354,600,000,000,000,000,000,000,000 | 5 | crypto,tls: implement safe x509 GeneralName format
This change introduces JSON-compatible escaping rules for strings that
include X.509 GeneralName components (see RFC 5280). This non-standard
format avoids ambiguities and prevents injection attacks that could
previously lead to X.509 certificates being accepted even though they
were not valid for the target hostname.
These changes affect the format of subject alternative names and the
format of authority information access. The checkServerIdentity function
has been modified to safely handle the new format, eliminating the
possibility of injecting subject alternative names into the verification
logic.
Because each subject alternative name is only encoded as a JSON string
literal if necessary for security purposes, this change will only be
visible in rare cases.
This addresses CVE-2021-44532.
CVE-ID: CVE-2021-44532
PR-URL: https://github.com/nodejs-private/node-private/pull/300
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Rich Trott <[email protected]> |
Variant c_SimpleXMLElementIterator::t_current() {
if (m_iter1 == nullptr) return uninit_null();
if (m_parent->m_is_attribute) {
return m_iter1->second();
}
ArrayIter *iter = m_iter2;
if (iter == nullptr && m_iter1->second().isObject()) {
iter = m_iter1;
}
if (iter) {
return iter->second();
}
assert(false);
return uninit_null();
} | 0 | [
"CWE-94"
]
| hhvm | 95f96e7287effe2fcdfb9a5338d1a7e4f55b083b | 82,518,600,454,851,750,000,000,000,000,000,000,000 | 18 | Fix libxml_disable_entity_loader()
This wasn't calling requestInit and setting the libxml handler no null.
So the first time an error came along it would reset the handler from
no-op to reading again.
This is a much better fix, we set our custom handler in requestInit and
when libxml_disable_entity_loader we store that state as a member bool
ensuring requestInit is always called to set our own handler.
If the handler isn't inserted then the behavious is as before. The only
time this could go pear shaped is say we wanted to make the default be
off. In that case we'd need a global requestInit that is always called
since there are libxml references everywhere.
Reviewed By: @jdelong
Differential Revision: D1116686 |
static int prepare_sdp_description(FFServerStream *stream, uint8_t **pbuffer,
struct in_addr my_ip)
{
AVFormatContext *avc;
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
AVDictionaryEntry *entry = av_dict_get(stream->metadata, "title", NULL, 0);
int i;
*pbuffer = NULL;
avc = avformat_alloc_context();
if (!avc || !rtp_format)
return -1;
avc->oformat = rtp_format;
av_dict_set(&avc->metadata, "title",
entry ? entry->value : "No Title", 0);
if (stream->is_multicast) {
snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
inet_ntoa(stream->multicast_ip),
stream->multicast_port, stream->multicast_ttl);
} else
snprintf(avc->filename, 1024, "rtp://0.0.0.0");
for(i = 0; i < stream->nb_streams; i++) {
AVStream *st = avformat_new_stream(avc, NULL);
if (!st)
goto sdp_done;
avcodec_parameters_from_context(stream->streams[i]->codecpar, stream->streams[i]->codec);
unlayer_stream(st, stream->streams[i]);
}
#define PBUFFER_SIZE 2048
*pbuffer = av_mallocz(PBUFFER_SIZE);
if (!*pbuffer)
goto sdp_done;
av_sdp_create(&avc, 1, *pbuffer, PBUFFER_SIZE);
sdp_done:
av_freep(&avc->streams);
av_dict_free(&avc->metadata);
av_free(avc);
return *pbuffer ? strlen(*pbuffer) : AVERROR(ENOMEM);
} | 0 | [
"CWE-119",
"CWE-787"
]
| FFmpeg | a5d25faa3f4b18dac737fdb35d0dd68eb0dc2156 | 339,065,813,932,518,400,000,000,000,000,000,000,000 | 44 | ffserver: Check chunk size
Fixes out of array access
Fixes: poc_ffserver.py
Found-by: Paul Cher <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]> |
evbuffer_incref_and_lock_(struct evbuffer *buf)
{
EVBUFFER_LOCK(buf);
++buf->refcnt;
} | 0 | [
"CWE-189"
]
| libevent | 841ecbd96105c84ac2e7c9594aeadbcc6fb38bc4 | 315,623,971,842,774,250,000,000,000,000,000,000,000 | 5 | Fix CVE-2014-6272 in Libevent 2.1
For this fix, we need to make sure that passing too-large inputs to
the evbuffer functions can't make us do bad things with the heap.
Also, lower the maximum chunk size to the lower of off_t, size_t maximum.
This is necessary since otherwise we could get into an infinite loop
if we make a chunk that 'misalign' cannot index into. |
recvauth_common(krb5_context context,
krb5_auth_context * auth_context,
/* IN */
krb5_pointer fd,
char *appl_version,
krb5_principal server,
krb5_int32 flags,
krb5_keytab keytab,
/* OUT */
krb5_ticket ** ticket,
krb5_data *version)
{
krb5_auth_context new_auth_context;
krb5_flags ap_option = 0;
krb5_error_code retval, problem;
krb5_data inbuf;
krb5_data outbuf;
krb5_rcache rcache = 0;
krb5_octet response;
krb5_data null_server;
int need_error_free = 0;
int local_rcache = 0, local_authcon = 0;
/*
* Zero out problem variable. If problem is set at the end of
* the intial version negotiation section, it means that we
* need to send an error code back to the client application
* and exit.
*/
problem = 0;
response = 0;
if (!(flags & KRB5_RECVAUTH_SKIP_VERSION)) {
/*
* First read the sendauth version string and check it.
*/
if ((retval = krb5_read_message(context, fd, &inbuf)))
return(retval);
if (strcmp(inbuf.data, sendauth_version)) {
problem = KRB5_SENDAUTH_BADAUTHVERS;
response = 1;
}
free(inbuf.data);
}
if (flags & KRB5_RECVAUTH_BADAUTHVERS) {
problem = KRB5_SENDAUTH_BADAUTHVERS;
response = 1;
}
/*
* Do the same thing for the application version string.
*/
if ((retval = krb5_read_message(context, fd, &inbuf)))
return(retval);
if (appl_version && strcmp(inbuf.data, appl_version)) {
if (!problem) {
problem = KRB5_SENDAUTH_BADAPPLVERS;
response = 2;
}
}
if (version && !problem)
*version = inbuf;
else
free(inbuf.data);
/*
* Now we actually write the response. If the response is non-zero,
* exit with a return value of problem
*/
if ((krb5_net_write(context, *((int *)fd), (char *)&response, 1)) < 0) {
return(problem); /* We'll return the top-level problem */
}
if (problem)
return(problem);
/* We are clear of errors here */
/*
* Now, let's read the AP_REQ message and decode it
*/
if ((retval = krb5_read_message(context, fd, &inbuf)))
return retval;
if (*auth_context == NULL) {
problem = krb5_auth_con_init(context, &new_auth_context);
*auth_context = new_auth_context;
local_authcon = 1;
}
krb5_auth_con_getrcache(context, *auth_context, &rcache);
if ((!problem) && rcache == NULL) {
/*
* Setup the replay cache.
*/
if (server != NULL && server->length > 0) {
problem = krb5_get_server_rcache(context, &server->data[0],
&rcache);
} else {
null_server.length = 7;
null_server.data = "default";
problem = krb5_get_server_rcache(context, &null_server, &rcache);
}
if (!problem)
problem = krb5_auth_con_setrcache(context, *auth_context, rcache);
local_rcache = 1;
}
if (!problem) {
problem = krb5_rd_req(context, auth_context, &inbuf, server,
keytab, &ap_option, ticket);
free(inbuf.data);
}
/*
* If there was a problem, send back a krb5_error message,
* preceeded by the length of the krb5_error message. If
* everything's ok, send back 0 for the length.
*/
if (problem) {
krb5_error error;
const char *message;
memset(&error, 0, sizeof(error));
krb5_us_timeofday(context, &error.stime, &error.susec);
if(server)
error.server = server;
else {
/* If this fails - ie. ENOMEM we are hosed
we cannot even send the error if we wanted to... */
(void) krb5_parse_name(context, "????", &error.server);
need_error_free = 1;
}
error.error = problem - ERROR_TABLE_BASE_krb5;
if (error.error > 127)
error.error = KRB_ERR_GENERIC;
message = error_message(problem);
error.text.length = strlen(message) + 1;
error.text.data = strdup(message);
if (!error.text.data) {
retval = ENOMEM;
goto cleanup;
}
if ((retval = krb5_mk_error(context, &error, &outbuf))) {
free(error.text.data);
goto cleanup;
}
free(error.text.data);
if(need_error_free)
krb5_free_principal(context, error.server);
} else {
outbuf.length = 0;
outbuf.data = 0;
}
retval = krb5_write_message(context, fd, &outbuf);
if (outbuf.data) {
free(outbuf.data);
/* We sent back an error, we need cleanup then return */
retval = problem;
goto cleanup;
}
if (retval)
goto cleanup;
/* Here lies the mutual authentication stuff... */
if ((ap_option & AP_OPTS_MUTUAL_REQUIRED)) {
if ((retval = krb5_mk_rep(context, *auth_context, &outbuf))) {
return(retval);
}
retval = krb5_write_message(context, fd, &outbuf);
free(outbuf.data);
}
cleanup:;
if (retval) {
if (local_authcon) {
krb5_auth_con_free(context, *auth_context);
} else if (local_rcache && rcache != NULL) {
krb5_rc_close(context, rcache);
krb5_auth_con_setrcache(context, *auth_context, NULL);
}
}
return retval;
} | 1 | [
"CWE-703"
]
| krb5 | 102bb6ebf20f9174130c85c3b052ae104e5073ec | 41,068,162,389,352,763,000,000,000,000,000,000,000 | 184 | Fix krb5_read_message handling [CVE-2014-5355]
In recvauth_common, do not use strcmp against the data fields of
krb5_data objects populated by krb5_read_message(), as there is no
guarantee that they are C strings. Instead, create an expected
krb5_data value and use data_eq().
In the sample user-to-user server application, check that the received
client principal name is null-terminated before using it with printf
and krb5_parse_name.
CVE-2014-5355:
In MIT krb5, when a server process uses the krb5_recvauth function, an
unauthenticated remote attacker can cause a NULL dereference by
sending a zero-byte version string, or a read beyond the end of
allocated storage by sending a non-null-terminated version string.
The example user-to-user server application (uuserver) is similarly
vulnerable to a zero-length or non-null-terminated principal name
string.
The krb5_recvauth function reads two version strings from the client
using krb5_read_message(), which produces a krb5_data structure
containing a length and a pointer to an octet sequence. krb5_recvauth
assumes that the data pointer is a valid C string and passes it to
strcmp() to verify the versions. If the client sends an empty octet
sequence, the data pointer will be NULL and strcmp() will dereference
a NULL pointer, causing the process to crash. If the client sends a
non-null-terminated octet sequence, strcmp() will read beyond the end
of the allocated storage, possibly causing the process to crash.
uuserver similarly uses krb5_read_message() to read a client principal
name, and then passes it to printf() and krb5_parse_name() without
verifying that it is a valid C string.
The krb5_recvauth function is used by kpropd and the Kerberized
versions of the BSD rlogin and rsh daemons. These daemons are usually
run out of inetd or in a mode which forks before processing incoming
connections, so a process crash will generally not result in a
complete denial of service.
Thanks to Tim Uglow for discovering this issue.
CVSSv2: AV:N/AC:L/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C
[[email protected]: CVSS score]
ticket: 8050 (new)
target_version: 1.13.1
tags: pullup |
countFrequencies (Int64 freq[HUF_ENCSIZE],
const unsigned short data[/*n*/],
int n)
#endif
{
for (int i = 0; i < HUF_ENCSIZE; ++i)
freq[i] = 0;
for (int i = 0; i < n; ++i)
++freq[data[i]];
} | 0 | [
"CWE-190"
]
| openexr | ed560b8a932c78d5e8e5990ce36fe7808b35d9f0 | 73,282,987,702,140,480,000,000,000,000,000,000,000 | 11 | prevent overflow in hufUncompress if nBits is large (#836)
Signed-off-by: Peter Hillman <[email protected]> |
flatpak_dir_update_summary (FlatpakDir *self,
GCancellable *cancellable,
GError **error)
{
g_auto(GLnxLockFile) lock = { 0, };
if (flatpak_dir_use_system_helper (self, NULL))
{
const char *installation = flatpak_dir_get_id (self);
return flatpak_dir_system_helper_call_update_summary (self,
FLATPAK_HELPER_UPDATE_SUMMARY_FLAGS_NONE,
installation ? installation : "",
cancellable,
error);
}
if (!flatpak_dir_ensure_repo (self, cancellable, error))
return FALSE;
/* Keep a shared repo lock to avoid prunes removing objects we're relying on
* while generating the summary. */
if (!flatpak_dir_repo_lock (self, &lock, LOCK_SH, cancellable, error))
return FALSE;
g_debug ("Updating summary");
return ostree_repo_regenerate_summary (self->repo, NULL, cancellable, error);
} | 0 | [
"CWE-668"
]
| flatpak | cd2142888fc4c199723a0dfca1f15ea8788a5483 | 38,842,782,169,919,937,000,000,000,000,000,000,000 | 28 | Don't expose /proc when running apply_extra
As shown by CVE-2019-5736, it is sometimes possible for the sandbox
app to access outside files using /proc/self/exe. This is not
typically an issue for flatpak as the sandbox runs as the user which
has no permissions to e.g. modify the host files.
However, when installing apps using extra-data into the system repo
we *do* actually run a sandbox as root. So, in this case we disable mounting
/proc in the sandbox, which will neuter attacks like this. |
static int pptp_call_clear_rqst(struct pptp_conn_t *conn)
{
struct pptp_call_clear_rqst *rqst = (struct pptp_call_clear_rqst *)conn->in_buf;
if (conf_verbose)
log_ppp_info2("recv [PPTP Call-Clear-Request <Call-ID %x>]\n", ntohs(rqst->call_id));
if (conn->echo_timer.tpd)
triton_timer_del(&conn->echo_timer);
if (conn->state == STATE_PPP) {
__sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_CLOSE;
ap_session_terminate(&conn->ppp.ses, TERM_USER_REQUEST, 1);
}
return send_pptp_call_disconnect_notify(conn, 4);
} | 0 | [
"CWE-787"
]
| accel-ppp | a0b8bfc4e74ff31b15ccfa6c626e3bbc591ba98f | 3,401,591,443,602,242,400,000,000,000,000,000,000 | 18 | Fix post_msg implementation bug
I think the error handling code of `post_msg` is wrongly implemented due to coding typo. The `EPIPE` should be also considered and then return -1, just like `PPTP_write`:
https://github.com/xebd/accel-ppp/blob/1b8711cf75a7c278d99840112bc7a396398e0205/accel-pppd/ctrl/pptp/pptp.c#L539-L570
This pr fixes #158. |
static int nsv_parse_NSVf_header(AVFormatContext *s)
{
NSVContext *nsv = s->priv_data;
AVIOContext *pb = s->pb;
unsigned int av_unused file_size;
unsigned int size;
int64_t duration;
int strings_size;
int table_entries;
int table_entries_used;
nsv->state = NSV_UNSYNC; /* in case we fail */
size = avio_rl32(pb);
if (size < 28)
return -1;
nsv->NSVf_end = size;
file_size = (uint32_t)avio_rl32(pb);
av_log(s, AV_LOG_TRACE, "NSV NSVf chunk_size %u\n", size);
av_log(s, AV_LOG_TRACE, "NSV NSVf file_size %u\n", file_size);
nsv->duration = duration = avio_rl32(pb); /* in ms */
av_log(s, AV_LOG_TRACE, "NSV NSVf duration %"PRId64" ms\n", duration);
// XXX: store it in AVStreams
strings_size = avio_rl32(pb);
table_entries = avio_rl32(pb);
table_entries_used = avio_rl32(pb);
av_log(s, AV_LOG_TRACE, "NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
strings_size, table_entries, table_entries_used);
if (avio_feof(pb))
return -1;
av_log(s, AV_LOG_TRACE, "NSV got header; filepos %"PRId64"\n", avio_tell(pb));
if (strings_size > 0) {
char *strings; /* last byte will be '\0' to play safe with str*() */
char *p, *endp;
char *token, *value;
char quote;
p = strings = av_mallocz((size_t)strings_size + 1);
if (!p)
return AVERROR(ENOMEM);
endp = strings + strings_size;
avio_read(pb, strings, strings_size);
while (p < endp) {
while (*p == ' ')
p++; /* strip out spaces */
if (p >= endp-2)
break;
token = p;
p = strchr(p, '=');
if (!p || p >= endp-2)
break;
*p++ = '\0';
quote = *p++;
value = p;
p = strchr(p, quote);
if (!p || p >= endp)
break;
*p++ = '\0';
av_log(s, AV_LOG_TRACE, "NSV NSVf INFO: %s='%s'\n", token, value);
av_dict_set(&s->metadata, token, value, 0);
}
av_free(strings);
}
if (avio_feof(pb))
return -1;
av_log(s, AV_LOG_TRACE, "NSV got infos; filepos %"PRId64"\n", avio_tell(pb));
if (table_entries_used > 0) {
int i;
nsv->index_entries = table_entries_used;
if((unsigned)table_entries_used >= UINT_MAX / sizeof(uint32_t))
return -1;
nsv->nsvs_file_offset = av_malloc_array((unsigned)table_entries_used, sizeof(uint32_t));
if (!nsv->nsvs_file_offset)
return AVERROR(ENOMEM);
for(i=0;i<table_entries_used;i++) {
if (avio_feof(pb))
return AVERROR_INVALIDDATA;
nsv->nsvs_file_offset[i] = avio_rl32(pb) + size;
}
if(table_entries > table_entries_used &&
avio_rl32(pb) == MKTAG('T','O','C','2')) {
nsv->nsvs_timestamps = av_malloc_array((unsigned)table_entries_used, sizeof(uint32_t));
if (!nsv->nsvs_timestamps)
return AVERROR(ENOMEM);
for(i=0;i<table_entries_used;i++) {
nsv->nsvs_timestamps[i] = avio_rl32(pb);
}
}
}
av_log(s, AV_LOG_TRACE, "NSV got index; filepos %"PRId64"\n", avio_tell(pb));
avio_seek(pb, nsv->base_offset + size, SEEK_SET); /* required for dumbdriving-271.nsv (2 extra bytes) */
if (avio_feof(pb))
return -1;
nsv->state = NSV_HAS_READ_NSVF;
return 0;
} | 0 | [
"CWE-703",
"CWE-834"
]
| FFmpeg | c24bcb553650b91e9eff15ef6e54ca73de2453b7 | 114,808,036,402,210,080,000,000,000,000,000,000,000 | 108 | avformat/nsvdec: Fix DoS due to lack of eof check in nsvs_file_offset loop.
Fixes: 20170829.nsv
Co-Author: 张洪亮(望初)" <[email protected]>
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <[email protected]> |
static int x509_crt_check_parent( const mbedtls_x509_crt *child,
const mbedtls_x509_crt *parent,
int top, int bottom )
{
int need_ca_bit;
/* Parent must be the issuer */
if( x509_name_cmp( &child->issuer, &parent->subject ) != 0 )
return( -1 );
/* Parent must have the basicConstraints CA bit set as a general rule */
need_ca_bit = 1;
/* Exception: v1/v2 certificates that are locally trusted. */
if( top && parent->version < 3 )
need_ca_bit = 0;
/* Exception: self-signed end-entity certs that are locally trusted. */
if( top && bottom &&
child->raw.len == parent->raw.len &&
memcmp( child->raw.p, parent->raw.p, child->raw.len ) == 0 )
{
need_ca_bit = 0;
}
if( need_ca_bit && ! parent->ca_istrue )
return( -1 );
#if defined(MBEDTLS_X509_CHECK_KEY_USAGE)
if( need_ca_bit &&
mbedtls_x509_crt_check_key_usage( parent, MBEDTLS_X509_KU_KEY_CERT_SIGN ) != 0 )
{
return( -1 );
}
#endif
return( 0 );
} | 0 | [
"CWE-287",
"CWE-284"
]
| mbedtls | d15795acd5074e0b44e71f7ede8bdfe1b48591fc | 68,872,047,206,211,170,000,000,000,000,000,000,000 | 38 | Improve behaviour on fatal errors
If we didn't walk the whole chain, then there may be any kind of errors in the
part of the chain we didn't check, so setting all flags looks like the safe
thing to do. |
parse_asntype(FILE * fp, char *name, int *ntype, char *ntoken)
{
int type, i;
char token[MAXTOKEN];
char quoted_string_buffer[MAXQUOTESTR];
char *hint = NULL;
char *descr = NULL;
struct tc *tcp;
int level;
type = get_token(fp, token, MAXTOKEN);
if (type == SEQUENCE || type == CHOICE) {
level = 0;
while ((type = get_token(fp, token, MAXTOKEN)) != ENDOFFILE) {
if (type == LEFTBRACKET) {
level++;
} else if (type == RIGHTBRACKET && --level == 0) {
*ntype = get_token(fp, ntoken, MAXTOKEN);
return NULL;
}
}
print_error("Expected \"}\"", token, type);
return NULL;
} else if (type == LEFTBRACKET) {
struct node *np;
int ch_next = '{';
ungetc(ch_next, fp);
np = parse_objectid(fp, name);
if (np != NULL) {
*ntype = get_token(fp, ntoken, MAXTOKEN);
return np;
}
return NULL;
} else if (type == LEFTSQBRACK) {
int size = 0;
do {
type = get_token(fp, token, MAXTOKEN);
} while (type != ENDOFFILE && type != RIGHTSQBRACK);
if (type != RIGHTSQBRACK) {
print_error("Expected \"]\"", token, type);
return NULL;
}
type = get_token(fp, token, MAXTOKEN);
if (type == IMPLICIT)
type = get_token(fp, token, MAXTOKEN);
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype == LEFTPAREN) {
switch (type) {
case OCTETSTR:
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype != SIZE) {
print_error("Expected SIZE", ntoken, *ntype);
return NULL;
}
size = 1;
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype != LEFTPAREN) {
print_error("Expected \"(\" after SIZE", ntoken,
*ntype);
return NULL;
}
/* FALL THROUGH */
case INTEGER:
*ntype = get_token(fp, ntoken, MAXTOKEN);
do {
if (*ntype != NUMBER)
print_error("Expected NUMBER", ntoken, *ntype);
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype == RANGE) {
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype != NUMBER)
print_error("Expected NUMBER", ntoken, *ntype);
*ntype = get_token(fp, ntoken, MAXTOKEN);
}
} while (*ntype == BAR);
if (*ntype != RIGHTPAREN) {
print_error("Expected \")\"", ntoken, *ntype);
return NULL;
}
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (size) {
if (*ntype != RIGHTPAREN) {
print_error("Expected \")\" to terminate SIZE",
ntoken, *ntype);
return NULL;
}
*ntype = get_token(fp, ntoken, MAXTOKEN);
}
}
}
return NULL;
} else {
if (type == CONVENTION) {
while (type != SYNTAX && type != ENDOFFILE) {
if (type == DISPLAYHINT) {
type = get_token(fp, token, MAXTOKEN);
if (type != QUOTESTRING) {
print_error("DISPLAY-HINT must be string", token,
type);
} else {
free(hint);
hint = strdup(token);
}
} else if (type == DESCRIPTION &&
netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SAVE_MIB_DESCRS)) {
type = get_token(fp, quoted_string_buffer, MAXQUOTESTR);
if (type != QUOTESTRING) {
print_error("DESCRIPTION must be string", token,
type);
} else {
free(descr);
descr = strdup(quoted_string_buffer);
}
} else
type =
get_token(fp, quoted_string_buffer, MAXQUOTESTR);
}
type = get_token(fp, token, MAXTOKEN);
if (type == OBJECT) {
type = get_token(fp, token, MAXTOKEN);
if (type != IDENTIFIER) {
print_error("Expected IDENTIFIER", token, type);
goto err;
}
type = OBJID;
}
} else if (type == OBJECT) {
type = get_token(fp, token, MAXTOKEN);
if (type != IDENTIFIER) {
print_error("Expected IDENTIFIER", token, type);
goto err;
}
type = OBJID;
}
if (type == LABEL) {
type = get_tc(token, current_module, NULL, NULL, NULL, NULL);
}
/*
* textual convention
*/
for (i = 0; i < MAXTC; i++) {
if (tclist[i].type == 0)
break;
}
if (i == MAXTC) {
print_error("Too many textual conventions", token, type);
goto err;
}
if (!(type & SYNTAX_MASK)) {
print_error("Textual convention doesn't map to real type",
token, type);
goto err;
}
tcp = &tclist[i];
tcp->modid = current_module;
tcp->descriptor = strdup(name);
tcp->hint = hint;
tcp->description = descr;
tcp->type = type;
*ntype = get_token(fp, ntoken, MAXTOKEN);
if (*ntype == LEFTPAREN) {
tcp->ranges = parse_ranges(fp, &tcp->ranges);
*ntype = get_token(fp, ntoken, MAXTOKEN);
} else if (*ntype == LEFTBRACKET) {
/*
* if there is an enumeration list, parse it
*/
tcp->enums = parse_enumlist(fp, &tcp->enums);
*ntype = get_token(fp, ntoken, MAXTOKEN);
}
return NULL;
}
err:
SNMP_FREE(descr);
SNMP_FREE(hint);
return NULL;
} | 0 | [
"CWE-59",
"CWE-61"
]
| net-snmp | 4fd9a450444a434a993bc72f7c3486ccce41f602 | 263,222,936,256,771,620,000,000,000,000,000,000,000 | 182 | CHANGES: snmpd: Stop reading and writing the mib_indexes/* files
Caching directory contents is something the operating system should do
and is not something Net-SNMP should do. Instead of storing a copy of
the directory contents in ${tmp_dir}/mib_indexes/${n}, always scan a
MIB directory. |
cmpspellaffix(const void *s1, const void *s2)
{
return (strncmp((*(SPELL *const *) s1)->p.flag, (*(SPELL *const *) s2)->p.flag, MAXFLAGLEN));
} | 0 | [
"CWE-119"
]
| postgres | 01824385aead50e557ca1af28640460fa9877d51 | 297,768,470,045,101,850,000,000,000,000,000,000,000 | 4 | Prevent potential overruns of fixed-size buffers.
Coverity identified a number of places in which it couldn't prove that a
string being copied into a fixed-size buffer would fit. We believe that
most, perhaps all of these are in fact safe, or are copying data that is
coming from a trusted source so that any overrun is not really a security
issue. Nonetheless it seems prudent to forestall any risk by using
strlcpy() and similar functions.
Fixes by Peter Eisentraut and Jozef Mlich based on Coverity reports.
In addition, fix a potential null-pointer-dereference crash in
contrib/chkpass. The crypt(3) function is defined to return NULL on
failure, but chkpass.c didn't check for that before using the result.
The main practical case in which this could be an issue is if libc is
configured to refuse to execute unapproved hashing algorithms (e.g.,
"FIPS mode"). This ideally should've been a separate commit, but
since it touches code adjacent to one of the buffer overrun changes,
I included it in this commit to avoid last-minute merge issues.
This issue was reported by Honza Horak.
Security: CVE-2014-0065 for buffer overruns, CVE-2014-0066 for crypt() |
static int release(struct socket *sock)
{
struct sock *sk = sock->sk;
struct tipc_port *tport;
struct sk_buff *buf;
int res;
/*
* Exit if socket isn't fully initialized (occurs when a failed accept()
* releases a pre-allocated child socket that was never used)
*/
if (sk == NULL)
return 0;
tport = tipc_sk_port(sk);
lock_sock(sk);
/*
* Reject all unreceived messages, except on an active connection
* (which disconnects locally & sends a 'FIN+' to peer)
*/
while (sock->state != SS_DISCONNECTING) {
buf = __skb_dequeue(&sk->sk_receive_queue);
if (buf == NULL)
break;
if (TIPC_SKB_CB(buf)->handle != NULL)
kfree_skb(buf);
else {
if ((sock->state == SS_CONNECTING) ||
(sock->state == SS_CONNECTED)) {
sock->state = SS_DISCONNECTING;
tipc_disconnect(tport->ref);
}
tipc_reject_msg(buf, TIPC_ERR_NO_PORT);
}
}
/*
* Delete TIPC port; this ensures no more messages are queued
* (also disconnects an active connection & sends a 'FIN-' to peer)
*/
res = tipc_deleteport(tport->ref);
/* Discard any remaining (connection-based) messages in receive queue */
__skb_queue_purge(&sk->sk_receive_queue);
/* Reject any messages that accumulated in backlog queue */
sock->state = SS_DISCONNECTING;
release_sock(sk);
sock_put(sk);
sock->sk = NULL;
return res;
} | 0 | [
"CWE-20",
"CWE-269"
]
| linux | f3d3342602f8bcbf37d7c46641cb9bca7618eb1c | 39,304,678,460,260,220,000,000,000,000,000,000,000 | 55 | net: rework recvmsg handler msg_name and msg_namelen logic
This patch now always passes msg->msg_namelen as 0. recvmsg handlers must
set msg_namelen to the proper size <= sizeof(struct sockaddr_storage)
to return msg_name to the user.
This prevents numerous uninitialized memory leaks we had in the
recvmsg handlers and makes it harder for new code to accidentally leak
uninitialized memory.
Optimize for the case recvfrom is called with NULL as address. We don't
need to copy the address at all, so set it to NULL before invoking the
recvmsg handler. We can do so, because all the recvmsg handlers must
cope with the case a plain read() is called on them. read() also sets
msg_name to NULL.
Also document these changes in include/linux/net.h as suggested by David
Miller.
Changes since RFC:
Set msg->msg_name = NULL if user specified a NULL in msg_name but had a
non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
affect sendto as it would bail out earlier while trying to copy-in the
address. It also more naturally reflects the logic by the callers of
verify_iovec.
With this change in place I could remove "
if (!uaddr || msg_sys->msg_namelen == 0)
msg->msg_name = NULL
".
This change does not alter the user visible error logic as we ignore
msg_namelen as long as msg_name is NULL.
Also remove two unnecessary curly brackets in ___sys_recvmsg and change
comments to netdev style.
Cc: David Miller <[email protected]>
Suggested-by: Eric Dumazet <[email protected]>
Signed-off-by: Hannes Frederic Sowa <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long addr, pud_t *pud)
{
return NULL;
} | 0 | []
| linux | a4a118f2eead1d6c49e00765de89878288d4b890 | 229,624,746,836,078,870,000,000,000,000,000,000,000 | 5 | hugetlbfs: flush TLBs correctly after huge_pmd_unshare
When __unmap_hugepage_range() calls to huge_pmd_unshare() succeed, a TLB
flush is missing. This TLB flush must be performed before releasing the
i_mmap_rwsem, in order to prevent an unshared PMDs page from being
released and reused before the TLB flush took place.
Arguably, a comprehensive solution would use mmu_gather interface to
batch the TLB flushes and the PMDs page release, however it is not an
easy solution: (1) try_to_unmap_one() and try_to_migrate_one() also call
huge_pmd_unshare() and they cannot use the mmu_gather interface; and (2)
deferring the release of the page reference for the PMDs page until
after i_mmap_rwsem is dropeed can confuse huge_pmd_unshare() into
thinking PMDs are shared when they are not.
Fix __unmap_hugepage_range() by adding the missing TLB flush, and
forcing a flush when unshare is successful.
Fixes: 24669e58477e ("hugetlb: use mmu_gather instead of a temporary linked list for accumulating pages)" # 3.6
Signed-off-by: Nadav Amit <[email protected]>
Reviewed-by: Mike Kravetz <[email protected]>
Cc: Aneesh Kumar K.V <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
term_job_ended(job_T *job)
{
term_T *term;
int did_one = FALSE;
for (term = first_term; term != NULL; term = term->tl_next)
if (term->tl_job == job)
{
VIM_CLEAR(term->tl_title);
VIM_CLEAR(term->tl_status_text);
redraw_buf_and_status_later(term->tl_buffer, VALID);
did_one = TRUE;
}
if (did_one)
redraw_statuslines();
if (curbuf->b_term != NULL)
{
if (curbuf->b_term->tl_job == job)
maketitle();
update_cursor(curbuf->b_term, TRUE);
}
} | 0 | [
"CWE-476"
]
| vim | cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8 | 40,744,191,473,891,296,000,000,000,000,000,000,000 | 22 | patch 8.1.0633: crash when out of memory while opening a terminal window
Problem: Crash when out of memory while opening a terminal window.
Solution: Handle out-of-memory more gracefully. |
Subsets and Splits