func
string
target
string
cwe
list
project
string
commit_id
string
hash
string
size
int64
message
string
vul
int64
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); }
Safe
[ "CWE-754" ]
mongo
f8f55e1825ee5c7bdb3208fc7c5b54321d172732
1.5390831921003002e+38
21
SERVER-44377 generate correct plan for indexed inequalities to null
0
struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct ovl_entry *oe; struct dentry *upperdir; struct dentry *lowerdir; struct dentry *upperdentry = NULL; struct dentry *lowerdentry = NULL; struct inode *inode = NULL; int err; err = -ENOMEM; oe = ovl_alloc_entry(); if (!oe) goto out; upperdir = ovl_dentry_upper(dentry->d_parent); lowerdir = ovl_dentry_lower(dentry->d_parent); if (upperdir) { upperdentry = ovl_lookup_real(upperdir, &dentry->d_name); err = PTR_ERR(upperdentry); if (IS_ERR(upperdentry)) goto out_put_dir; if (lowerdir && upperdentry) { if (ovl_is_whiteout(upperdentry)) { dput(upperdentry); upperdentry = NULL; oe->opaque = true; } else if (ovl_is_opaquedir(upperdentry)) { oe->opaque = true; } } } if (lowerdir && !oe->opaque) { lowerdentry = ovl_lookup_real(lowerdir, &dentry->d_name); err = PTR_ERR(lowerdentry); if (IS_ERR(lowerdentry)) goto out_dput_upper; } if (lowerdentry && upperdentry && (!S_ISDIR(upperdentry->d_inode->i_mode) || !S_ISDIR(lowerdentry->d_inode->i_mode))) { dput(lowerdentry); lowerdentry = NULL; oe->opaque = true; } if (lowerdentry || upperdentry) { struct dentry *realdentry; realdentry = upperdentry ? upperdentry : lowerdentry; err = -ENOMEM; inode = ovl_new_inode(dentry->d_sb, realdentry->d_inode->i_mode, oe); if (!inode) goto out_dput; ovl_copyattr(realdentry->d_inode, inode); } oe->__upperdentry = upperdentry; oe->lowerdentry = lowerdentry; dentry->d_fsdata = oe; d_add(dentry, inode); return NULL; out_dput: dput(lowerdentry); out_dput_upper: dput(upperdentry); out_put_dir: kfree(oe); out: return ERR_PTR(err); }
Safe
[ "CWE-284", "CWE-264" ]
linux
69c433ed2ecd2d3264efd7afec4439524b319121
4.148977435386449e+37
79
fs: limit filesystem stacking depth Add a simple read-only counter to super_block that indicates how deep this is in the stack of filesystems. Previously ecryptfs was the only stackable filesystem and it explicitly disallowed multiple layers of itself. Overlayfs, however, can be stacked recursively and also may be stacked on top of ecryptfs or vice versa. To limit the kernel stack usage we must limit the depth of the filesystem stack. Initially the limit is set to 2. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
0
explicit FormatError(CStringRef message) : std::runtime_error(message.c_str()) {}
Safe
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
5.856371676392378e+37
2
Fix segfault on complex pointer formatting (#642)
0
GF_Err gmin_box_size(GF_Box *s) { GF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s; ptr->size += 12; return GF_OK; }
Safe
[ "CWE-476" ]
gpac
6170024568f4dda310e98ef7508477b425c58d09
2.4286549460872466e+38
6
fixed potential crash - cf #1263
0
vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx, Vmxnet3PktStatus status) { size_t tot_len = net_tx_pkt_get_total_len(s->tx_pkt); struct UPT1_TxStats *stats = &s->txq_descr[qidx].txq_stats; switch (status) { case VMXNET3_PKT_STATUS_OK: switch (net_tx_pkt_get_packet_type(s->tx_pkt)) { case ETH_PKT_BCAST: stats->bcastPktsTxOK++; stats->bcastBytesTxOK += tot_len; break; case ETH_PKT_MCAST: stats->mcastPktsTxOK++; stats->mcastBytesTxOK += tot_len; break; case ETH_PKT_UCAST: stats->ucastPktsTxOK++; stats->ucastBytesTxOK += tot_len; break; default: g_assert_not_reached(); } if (s->offload_mode == VMXNET3_OM_TSO) { /* * According to VMWARE headers this statistic is a number * of packets after segmentation but since we don't have * this information in QEMU model, the best we can do is to * provide number of non-segmented packets */ stats->TSOPktsTxOK++; stats->TSOBytesTxOK += tot_len; } break; case VMXNET3_PKT_STATUS_DISCARD: stats->pktsTxDiscard++; break; case VMXNET3_PKT_STATUS_ERROR: stats->pktsTxError++; break; default: g_assert_not_reached(); } }
Safe
[ "CWE-416" ]
qemu
6c352ca9b4ee3e1e286ea9e8434bd8e69ac7d0d8
7.99849576768915e+37
49
net: vmxnet3: check for device_active before write Vmxnet3 device emulator does not check if the device is active, before using it for write. It leads to a use after free issue, if the vmxnet3_io_bar0_write routine is called after the device is deactivated. Add check to avoid it. Reported-by: Li Qiang <liqiang6-s@360.cn> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> Acked-by: Dmitry Fleytman <dmitry@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
0
DIR *dd_init_next_file(struct dump_dir *dd) { // if (!dd->locked) // error_msg_and_die("dump_dir is not opened"); /* bug */ int opendir_fd = dup(dd->dd_fd); if (opendir_fd < 0) { perror_msg("dd_init_next_file: dup(dd_fd)"); return NULL; } if (dd->next_dir) closedir(dd->next_dir); dd->next_dir = fdopendir(opendir_fd); if (!dd->next_dir) { error_msg("Can't open directory '%s'", dd->dd_dirname); } return dd->next_dir; }
Safe
[ "CWE-20" ]
libreport
1951e7282043dfe1268d492aea056b554baedb75
1.3931824274085878e+38
22
lib: fix races in dump directory handling code Florian Weimer <fweimer@redhat.com>: dd_opendir() should keep a file handle (opened with O_DIRECTORY) and use openat() and similar functions to access files in it. ... The file system manipulation functions should guard against hard links (check that link count is <= 1, just as in the user coredump code in abrt-hook-ccpp), possibly after opening the file with O_PATH first to avoid side effects on open/close. Related: #1214745 Signed-off-by: Jakub Filak <jfilak@redhat.com>
0
ref_param_read_signal_error(gs_param_list * plist, gs_param_name pkey, int code) { iparam_list *const iplist = (iparam_list *) plist; iparam_loc loc; ref_param_read(iplist, pkey, &loc, -1); /* can't fail */ *loc.presult = code; switch (ref_param_read_get_policy(plist, pkey)) { case gs_param_policy_ignore: return 0; case gs_param_policy_consult_user: return_error(gs_error_configurationerror); default: return code; } }
Vulnerable
[]
ghostpdl
c3476dde7743761a4e1d39a631716199b696b880
1.6867390336015571e+38
16
Bug 699656: Handle LockDistillerParams not being a boolean This caused a function call commented as "Can't fail" to fail, and resulted in memory correuption and a segfault.
1
void kvm_arch_sync_events(struct kvm *kvm) { kvm_free_all_assigned_devices(kvm); }
Safe
[ "CWE-476" ]
linux-2.6
59839dfff5eabca01cc4e20b45797a60a80af8cb
1.673435382710701e+38
4
KVM: x86: check for cr3 validity in ioctl_set_sregs Matt T. Yourst notes that kvm_arch_vcpu_ioctl_set_sregs lacks validity checking for the new cr3 value: "Userspace callers of KVM_SET_SREGS can pass a bogus value of cr3 to the kernel. This will trigger a NULL pointer access in gfn_to_rmap() when userspace next tries to call KVM_RUN on the affected VCPU and kvm attempts to activate the new non-existent page table root. This happens since kvm only validates that cr3 points to a valid guest physical memory page when code *inside* the guest sets cr3. However, kvm currently trusts the userspace caller (e.g. QEMU) on the host machine to always supply a valid page table root, rather than properly validating it along with the rest of the reloaded guest state." http://sourceforge.net/tracker/?func=detail&atid=893831&aid=2687641&group_id=180599 Check for a valid cr3 address in kvm_arch_vcpu_ioctl_set_sregs, triple fault in case of failure. Cc: stable@kernel.org Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
0
static uint get_decimal_precision(uint len, uint8 dec, bool unsigned_val) { uint precision= my_decimal_length_to_precision(len, dec, unsigned_val); return MY_MIN(precision, DECIMAL_MAX_PRECISION); }
Safe
[ "CWE-416", "CWE-703" ]
server
08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917
1.8510351165682454e+38
5
MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if() vcol_info->expr is allocated on expr_arena at parsing stage. Since expr item is allocated on expr_arena all its containee items must be allocated on expr_arena too. Otherwise fix_session_expr() will encounter prematurely freed item. When table is reopened from cache vcol_info contains stale expression. We refresh expression via TABLE::vcol_fix_exprs() but first we must prepare a proper context (Vcol_expr_context) which meets some requirements: 1. As noted above expr update must be done on expr_arena as there may be new items created. It was a bug in fix_session_expr_for_read() and was just not reproduced because of no second refix. Now refix is done for more cases so it does reproduce. Tests affected: vcol.binlog 2. Also name resolution context must be narrowed to the single table. Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes 3. sql_mode must be clean and not fail expr update. sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc must not affect vcol expression update. If the table was created successfully any further evaluation must not fail. Tests affected: main.func_like Reviewed by: Sergei Golubchik <serg@mariadb.org>
0
ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|CV, CONST|TMPVAR|CV) { USE_OPLINE zend_free_op free_op1, free_op2; zval *container; zval *offset; zend_ulong hval; zend_string *key; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_UNSET); offset = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R); do { if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { HashTable *ht; ZEND_VM_C_LABEL(unset_dim_array): SEPARATE_ARRAY(container); ht = Z_ARRVAL_P(container); ZEND_VM_C_LABEL(offset_again): if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) { key = Z_STR_P(offset); if (OP2_TYPE != IS_CONST) { if (ZEND_HANDLE_NUMERIC(key, hval)) { ZEND_VM_C_GOTO(num_index_dim); } } ZEND_VM_C_LABEL(str_index_dim): if (ht == &EG(symbol_table)) { zend_delete_global_variable(key); } else { zend_hash_del(ht, key); } } else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) { hval = Z_LVAL_P(offset); ZEND_VM_C_LABEL(num_index_dim): zend_hash_index_del(ht, hval); } else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) { offset = Z_REFVAL_P(offset); ZEND_VM_C_GOTO(offset_again); } else if (Z_TYPE_P(offset) == IS_DOUBLE) { hval = zend_dval_to_lval(Z_DVAL_P(offset)); ZEND_VM_C_GOTO(num_index_dim); } else if (Z_TYPE_P(offset) == IS_NULL) { key = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index_dim); } else if (Z_TYPE_P(offset) == IS_FALSE) { hval = 0; ZEND_VM_C_GOTO(num_index_dim); } else if (Z_TYPE_P(offset) == IS_TRUE) { hval = 1; ZEND_VM_C_GOTO(num_index_dim); } else if (Z_TYPE_P(offset) == IS_RESOURCE) { hval = Z_RES_HANDLE_P(offset); ZEND_VM_C_GOTO(num_index_dim); } else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) { ZVAL_UNDEFINED_OP2(); key = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index_dim); } else { zend_error(E_WARNING, "Illegal offset type in unset"); } break; } else if (Z_ISREF_P(container)) { container = Z_REFVAL_P(container); if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) { ZEND_VM_C_GOTO(unset_dim_array); } } if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) { container = ZVAL_UNDEFINED_OP1(); } if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) { offset = ZVAL_UNDEFINED_OP2(); } if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) { if (OP2_TYPE == IS_CONST && Z_EXTRA_P(offset) == ZEND_EXTRA_VALUE) { offset++; } Z_OBJ_HT_P(container)->unset_dimension(container, offset); } else if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) { zend_throw_error(NULL, "Cannot unset string offsets"); } } while (0); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); }
Safe
[ "CWE-787" ]
php-src
f1ce8d5f5839cb2069ea37ff424fb96b8cd6932d
2.1774566225427334e+38
90
Fix #73122: Integer Overflow when concatenating strings We must avoid integer overflows in memory allocations, so we introduce an additional check in the VM, and bail out in the rare case of an overflow. Since the recent fix for bug #74960 still doesn't catch all possible overflows, we fix that right away.
0
static int mt_process_slot(struct mt_device *td, struct input_dev *input, struct mt_application *app, struct mt_usages *slot) { struct input_mt *mt = input->mt; __s32 quirks = app->quirks; bool valid = true; bool confidence_state = true; bool inrange_state = false; int active; int slotnum; int tool = MT_TOOL_FINGER; if (!slot) return -EINVAL; if ((quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && app->num_received >= app->num_expected) return -EAGAIN; if (!(quirks & MT_QUIRK_ALWAYS_VALID)) { if (quirks & MT_QUIRK_VALID_IS_INRANGE) valid = *slot->inrange_state; if (quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) valid = *slot->tip_state; if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) valid = *slot->confidence_state; if (!valid) return 0; } slotnum = mt_compute_slot(td, app, slot, input); if (slotnum < 0 || slotnum >= td->maxcontacts) return 0; if ((quirks & MT_QUIRK_IGNORE_DUPLICATES) && mt) { struct input_mt_slot *i_slot = &mt->slots[slotnum]; if (input_mt_is_active(i_slot) && input_mt_is_used(mt, i_slot)) return -EAGAIN; } if (quirks & MT_QUIRK_CONFIDENCE) confidence_state = *slot->confidence_state; if (quirks & MT_QUIRK_HOVERING) inrange_state = *slot->inrange_state; active = *slot->tip_state || inrange_state; if (app->application == HID_GD_SYSTEM_MULTIAXIS) tool = MT_TOOL_DIAL; else if (unlikely(!confidence_state)) { tool = MT_TOOL_PALM; if (!active && mt && input_mt_is_active(&mt->slots[slotnum])) { /* * The non-confidence was reported for * previously valid contact that is also no * longer valid. We can't simply report * lift-off as userspace will not be aware * of non-confidence, so we need to split * it into 2 events: active MT_TOOL_PALM * and a separate liftoff. */ active = true; set_bit(slotnum, app->pending_palm_slots); } } input_mt_slot(input, slotnum); input_mt_report_slot_state(input, tool, active); if (active) { /* this finger is in proximity of the sensor */ int wide = (*slot->w > *slot->h); int major = max(*slot->w, *slot->h); int minor = min(*slot->w, *slot->h); int orientation = wide; int max_azimuth; int azimuth; if (slot->a != DEFAULT_ZERO) { /* * Azimuth is counter-clockwise and ranges from [0, MAX) * (a full revolution). Convert it to clockwise ranging * [-MAX/2, MAX/2]. * * Note that ABS_MT_ORIENTATION require us to report * the limit of [-MAX/4, MAX/4], but the value can go * out of range to [-MAX/2, MAX/2] to report an upside * down ellipsis. */ azimuth = *slot->a; max_azimuth = input_abs_get_max(input, ABS_MT_ORIENTATION); if (azimuth > max_azimuth * 2) azimuth -= max_azimuth * 4; orientation = -azimuth; } if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { /* * divided by two to match visual scale of touch * for devices with this quirk */ major = major >> 1; minor = minor >> 1; } input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); input_event(input, EV_ABS, ABS_MT_TOOL_Y, *slot->cy); input_event(input, EV_ABS, ABS_MT_DISTANCE, !*slot->tip_state); input_event(input, EV_ABS, ABS_MT_ORIENTATION, orientation); input_event(input, EV_ABS, ABS_MT_PRESSURE, *slot->p); input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); } return 0; }
Safe
[ "CWE-787" ]
linux
35556bed836f8dc07ac55f69c8d17dce3e7f0e25
2.3154462929050986e+38
126
HID: core: Sanitize event code and type when mapping input When calling into hid_map_usage(), the passed event code is blindly stored as is, even if it doesn't fit in the associated bitmap. This event code can come from a variety of sources, including devices masquerading as input devices, only a bit more "programmable". Instead of taking the event code at face value, check that it actually fits the corresponding bitmap, and if it doesn't: - spit out a warning so that we know which device is acting up - NULLify the bitmap pointer so that we catch unexpected uses Code paths that can make use of untrusted inputs can now check that the mapping was indeed correct and bail out if not. Cc: stable@vger.kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
0
pdf14_end_transparency_group(gx_device *dev, gs_gstate *pgs) { pdf14_device *pdev = (pdf14_device *)dev; int code; pdf14_parent_color_t *parent_color; cmm_profile_t *group_profile; gsicc_rendering_param_t render_cond; cmm_dev_profile_t *dev_profile; code = dev_proc(dev, get_profile)(dev, &dev_profile); if (code < 0) return code; gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &group_profile, &render_cond); if_debug0m('v', dev->memory, "[v]pdf14_end_transparency_group\n"); code = pdf14_pop_transparency_group(pgs, pdev->ctx, pdev->blend_procs, pdev->color_info.num_components, group_profile, (gx_device *) pdev); #ifdef DEBUG pdf14_debug_mask_stack_state(pdev->ctx); #endif /* May need to reset some color stuff related * to a mismatch between the parents color space * and the group blending space */ parent_color = pdev->ctx->stack->parent_color_info_procs; if (!(parent_color->parent_color_mapping_procs == NULL && parent_color->parent_color_comp_index == NULL)) { pgs->get_cmap_procs = parent_color->get_cmap_procs; gx_set_cmap_procs(pgs, dev); pdev->procs.get_color_mapping_procs = parent_color->parent_color_mapping_procs; pdev->procs.get_color_comp_index = parent_color->parent_color_comp_index; pdev->color_info.polarity = parent_color->polarity; pdev->color_info.num_components = parent_color->num_components; pdev->blend_procs = parent_color->parent_blending_procs; pdev->ctx->additive = parent_color->isadditive; pdev->pdf14_procs = parent_color->unpack_procs; pdev->color_info.depth = parent_color->depth; pdev->color_info.max_color = parent_color->max_color; pdev->color_info.max_gray = parent_color->max_gray; memcpy(&(pdev->color_info.comp_bits),&(parent_color->comp_bits), GX_DEVICE_COLOR_MAX_COMPONENTS); memcpy(&(pdev->color_info.comp_shift),&(parent_color->comp_shift), GX_DEVICE_COLOR_MAX_COMPONENTS); parent_color->get_cmap_procs = NULL; parent_color->parent_color_comp_index = NULL; parent_color->parent_color_mapping_procs = NULL; if (parent_color->icc_profile != NULL) { /* make sure to decrement the device profile. If it was allocated with the push then it will be freed. */ rc_decrement(group_profile,"pdf14_end_transparency_group"); dev->icc_struct->device_profile[0] = parent_color->icc_profile; rc_decrement(parent_color->icc_profile,"pdf14_end_transparency_group"); parent_color->icc_profile = NULL; } } return code; }
Safe
[ "CWE-416" ]
ghostpdl
90fd0c7ca3efc1ddff64a86f4104b13b3ac969eb
1.6522456642873473e+38
60
Bug 697456. Dont create new ctx when pdf14 device reenabled This bug had yet another weird case where the user created a file that pushed the pdf14 device twice. We were in that case, creating a new ctx and blowing away the original one with out proper clean up. To avoid, only create a new one when we need it.
0
read_16 (IOBUF inp) { unsigned short a; a = (unsigned short)iobuf_get_noeof (inp) << 8; a |= iobuf_get_noeof (inp); return a; }
Safe
[ "CWE-20" ]
gnupg
2183683bd633818dd031b090b5530951de76f392
1.0863539951921465e+38
7
Use inline functions to convert buffer data to scalars. * common/host2net.h (buf16_to_ulong, buf16_to_uint): New. (buf16_to_ushort, buf16_to_u16): New. (buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New. -- Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to avoid all sign extension on shift problems. Hanno Böck found a case with an invalid read due to this problem. To fix that once and for all almost all uses of "<< 24" and "<< 8" are changed by this patch to use an inline function from host2net.h. Signed-off-by: Werner Koch <wk@gnupg.org>
0
char_superscript(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size) { size_t sup_start, sup_len; struct buf *sup; if (!rndr->cb.superscript) return 0; if (size < 2) return 0; if (data[1] == '(') { sup_start = sup_len = 2; while (sup_len < size && data[sup_len] != ')' && data[sup_len - 1] != '\\') sup_len++; if (sup_len == size) return 0; } else { sup_start = sup_len = 1; while (sup_len < size && !_isspace(data[sup_len])) sup_len++; } if (sup_len - sup_start == 0) return (sup_start == 2) ? 3 : 0; sup = rndr_newbuf(rndr, BUFFER_SPAN); parse_inline(sup, rndr, data + sup_start, sup_len - sup_start); rndr->cb.superscript(ob, sup, rndr->opaque); rndr_popbuf(rndr, BUFFER_SPAN); return (sup_start == 2) ? sup_len + 1 : sup_len; }
Safe
[]
redcarpet
e5a10516d07114d582d13b9125b733008c61c242
5.665664270312272e+37
36
Avoid rewinding previous inline when auto-linking When a bit like "_foo_1@bar.com" is processed, first the emphasis is rendered, then the 1 is output verbatim. When the `@` is encountered, Redcarpet tries to find the "local part" of the address and stops when it encounters an invalid char (i.e. here the `!`). The problem is that when it searches for the local part, Redcarpet rewinds the characters but here, the emphasis is already rendered so the previous HTML tag is rewinded as well and is not correctly closed.
0
static void mark_reg_known_zero(struct bpf_verifier_env *env, struct bpf_reg_state *regs, u32 regno) { if (WARN_ON(regno >= MAX_BPF_REG)) { verbose(env, "mark_reg_known_zero(regs, %u)\n", regno); /* Something bad happened, let's kill all regs */ for (regno = 0; regno < MAX_BPF_REG; regno++) __mark_reg_not_init(regs + regno); return; } __mark_reg_known_zero(regs + regno); }
Safe
[ "CWE-20" ]
linux
c131187db2d3fa2f8bf32fdf4e9a4ef805168467
3.746645751519591e+37
12
bpf: fix branch pruning logic when the verifier detects that register contains a runtime constant and it's compared with another constant it will prune exploration of the branch that is guaranteed not to be taken at runtime. This is all correct, but malicious program may be constructed in such a way that it always has a constant comparison and the other branch is never taken under any conditions. In this case such path through the program will not be explored by the verifier. It won't be taken at run-time either, but since all instructions are JITed the malicious program may cause JITs to complain about using reserved fields, etc. To fix the issue we have to track the instructions explored by the verifier and sanitize instructions that are dead at run time with NOPs. We cannot reject such dead code, since llvm generates it for valid C code, since it doesn't do as much data flow analysis as the verifier does. Fixes: 17a5267067f3 ("bpf: verifier (add verifier core)") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
0
vhost_crypto_finalize_one_request(struct rte_crypto_op *op, struct vhost_virtqueue *old_vq) { struct rte_mbuf *m_src = op->sym->m_src; struct rte_mbuf *m_dst = op->sym->m_dst; struct vhost_crypto_data_req *vc_req = rte_mbuf_to_priv(m_src); uint16_t desc_idx; if (unlikely(!vc_req)) { VC_LOG_ERR("Failed to retrieve vc_req"); return NULL; } if (old_vq && (vc_req->vq != old_vq)) return vc_req->vq; desc_idx = vc_req->desc_idx; if (unlikely(op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) vc_req->inhdr->status = VIRTIO_CRYPTO_ERR; else { if (vc_req->zero_copy == 0) write_back_data(vc_req); } vc_req->vq->used->ring[desc_idx].id = desc_idx; vc_req->vq->used->ring[desc_idx].len = vc_req->len; rte_mempool_put(m_src->pool, (void *)m_src); if (m_dst) rte_mempool_put(m_dst->pool, (void *)m_dst); return vc_req->vq; }
Safe
[ "CWE-125" ]
dpdk
acd4c92fa693bbea695f2bb42bb93fb8567c3ca5
2.216724769047399e+38
35
vhost/crypto: validate keys lengths transform_cipher_param() and transform_chain_param() handle the payload data for the VHOST_USER_CRYPTO_CREATE_SESS message. These payloads have to be validated, since it could come from untrusted sources. Two buffers and their lengths are defined in this payload, one the the auth key and one for the cipher key. But above functions do not validate the key length inputs, which could lead to read out of bounds, as buffers have static sizes of 64 bytes for the cipher key and 512 bytes for the auth key. This patch adds necessary checks on the key length field before being used. CVE-2020-10724 Fixes: e80a98708166 ("vhost/crypto: add session message handler") Cc: stable@dpdk.org Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com> Reviewed-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
0
MONGO_EXPORT void mongo_init_sockets( void ) { mongo_env_sock_init(); }
Safe
[ "CWE-190" ]
mongo-c-driver-legacy
1a1f5e26a4309480d88598913f9eebf9e9cba8ca
6.972739440925013e+36
3
don't mix up int and size_t (first pass to fix that)
0
void visit(Repetition &ope) override { if (ope.max_ == std::numeric_limits<size_t>::max()) { HasEmptyElement vis(refs_); ope.ope_->accept(vis); if (vis.is_empty) { has_error = true; error_s = vis.error_s; error_name = vis.error_name; } } else { ope.ope_->accept(*this); } }
Safe
[ "CWE-125" ]
cpp-peglib
b3b29ce8f3acf3a32733d930105a17d7b0ba347e
2.359891652148546e+38
13
Fix #122
0
static VALUE mString_Extend_json_create(VALUE self, VALUE o) { VALUE ary; Check_Type(o, T_HASH); ary = rb_hash_aref(o, rb_str_new2("raw")); return rb_funcall(ary, i_pack, 1, rb_str_new2("C*")); }
Safe
[ "CWE-119", "CWE-787" ]
json
8f782fd8e181d9cfe9387ded43a5ca9692266b85
2.1316429788548147e+38
7
Fix arbitrary heap exposure problem
0
Perl_same_dirent(pTHX_ const char *a, const char *b) { char *fa = strrchr(a,'/'); char *fb = strrchr(b,'/'); Stat_t tmpstatbuf1; Stat_t tmpstatbuf2; SV * const tmpsv = sv_newmortal(); PERL_ARGS_ASSERT_SAME_DIRENT; if (fa) fa++; else fa = a; if (fb) fb++; else fb = b; if (strNE(a,b)) return FALSE; if (fa == a) sv_setpvs(tmpsv, "."); else sv_setpvn(tmpsv, a, fa - a); if (PerlLIO_stat(SvPVX_const(tmpsv), &tmpstatbuf1) < 0) return FALSE; if (fb == b) sv_setpvs(tmpsv, "."); else sv_setpvn(tmpsv, b, fb - b); if (PerlLIO_stat(SvPVX_const(tmpsv), &tmpstatbuf2) < 0) return FALSE; return tmpstatbuf1.st_dev == tmpstatbuf2.st_dev && tmpstatbuf1.st_ino == tmpstatbuf2.st_ino; }
Safe
[ "CWE-119", "CWE-703", "CWE-787" ]
perl5
34716e2a6ee2af96078d62b065b7785c001194be
2.1654834301685256e+38
35
Perl_my_setenv(); handle integer wrap RT #133204 Wean this function off int/I32 and onto UV/Size_t. Also, replace all malloc-ish calls with a wrapper that does overflow checks, In particular, it was doing (nlen + vlen + 2) which could wrap when the combined length of the environment variable name and value exceeded around 0x7fffffff. The wrapper check function is probably overkill, but belt and braces... NB this function has several variant parts, #ifdef'ed by platform type; I have blindly changed the parts that aren't compiled under linux.
0
void GraphConstructor::RemapNodeDefInputs( NodeDef* node_def, std::vector<bool>* input_already_exists) { DCHECK_EQ(input_already_exists->size(), node_def->input_size()); std::set<TensorId> control_inputs; std::vector<int> inputs_to_remove; for (int i = 0; i < node_def->input_size(); ++i) { auto iter = opts_.input_map.find(ParseTensorName(node_def->input(i))); if (iter == opts_.input_map.end()) continue; used_input_map_keys_.insert(iter->first); TensorId new_input = iter->second; if (new_input.second == Graph::kControlSlot) { // Check if we've already remapped a different input to new_input, and if // so remove this input. if (control_inputs.count(new_input) > 0) { inputs_to_remove.push_back(i); continue; } control_inputs.insert(new_input); } node_def->set_input(i, new_input.ToString()); (*input_already_exists)[i] = true; } if (!inputs_to_remove.empty()) { RemoveInputs(inputs_to_remove, node_def, input_already_exists); } }
Safe
[ "CWE-125", "CWE-369", "CWE-908" ]
tensorflow
0cc38aaa4064fd9e79101994ce9872c6d91f816b
1.6518807723445805e+38
28
Prevent unitialized memory access in `GraphConstructor::MakeEdge` The `MakeEdge` implementation assumes that there exists an output at `output_index` of `src` node and an input at `input_index` of `dst` node. However, if this is not the case this results in accessing data out of bounds. Because we are accessing an array that is a private member of a class and only in read only mode, this usually results only in unitialized memory access. However, it is reasonable to think that malicious users could manipulate these indexes to actually read data outside the class, thus resulting in information leakage and further exploits. PiperOrigin-RevId: 346343288 Change-Id: I2127da27c2023d27f26efd39afa6c853385cab6f
0
static int on_ppp_if_down(struct tunnel *tunnel) { log_info("Setting ppp interface down.\n"); if (tunnel->config->set_routes) { log_info("Restoring routes...\n"); ipv4_restore_routes(tunnel); } if (tunnel->config->set_dns) { log_info("Removing VPN nameservers...\n"); ipv4_del_nameservers_from_resolv_conf(tunnel); } return 0; }
Safe
[ "CWE-295" ]
openfortivpn
60660e00b80bad0fadcf39aee86f6f8756c94f91
2.1887722788351492e+38
16
correctly check return value of X509_check_host CVE-2020-7041 incorrect use of X509_check_host (regarding return value) is fixed with this commit. The flaw came in with #242 and prevented proper host name verification when openssl >= 1.0.2 was in use since openfortivpn 1.7.0.
0
int dev_change_net_namespace(struct net_device *dev, struct net *net, const char *pat) { int err; ASSERT_RTNL(); /* Don't allow namespace local devices to be moved. */ err = -EINVAL; if (dev->features & NETIF_F_NETNS_LOCAL) goto out; /* Ensure the device has been registrered */ if (dev->reg_state != NETREG_REGISTERED) goto out; /* Get out if there is nothing todo */ err = 0; if (net_eq(dev_net(dev), net)) goto out; /* Pick the destination device name, and ensure * we can use it in the destination network namespace. */ err = -EEXIST; if (__dev_get_by_name(net, dev->name)) { /* We get here if we can't use the current device name */ if (!pat) goto out; if (dev_get_valid_name(net, dev, pat) < 0) goto out; } /* * And now a mini version of register_netdevice unregister_netdevice. */ /* If device is running close it first. */ dev_close(dev); /* And unlink it from device chain */ err = -ENODEV; unlist_netdevice(dev); synchronize_net(); /* Shutdown queueing discipline. */ dev_shutdown(dev); /* Notify protocols, that we are about to destroy this device. They should clean all the things. Note that dev->reg_state stays at NETREG_REGISTERED. This is wanted because this way 8021q and macvlan know the device is just moving and can keep their slaves up. */ call_netdevice_notifiers(NETDEV_UNREGISTER, dev); rcu_barrier(); call_netdevice_notifiers(NETDEV_UNREGISTER_FINAL, dev); rtmsg_ifinfo(RTM_DELLINK, dev, ~0U, GFP_KERNEL); /* * Flush the unicast and multicast chains */ dev_uc_flush(dev); dev_mc_flush(dev); /* Send a netdev-removed uevent to the old namespace */ kobject_uevent(&dev->dev.kobj, KOBJ_REMOVE); /* Actually switch the network namespace */ dev_net_set(dev, net); /* If there is an ifindex conflict assign a new one */ if (__dev_get_by_index(net, dev->ifindex)) { int iflink = (dev->iflink == dev->ifindex); dev->ifindex = dev_new_index(net); if (iflink) dev->iflink = dev->ifindex; } /* Send a netdev-add uevent to the new namespace */ kobject_uevent(&dev->dev.kobj, KOBJ_ADD); /* Fixup kobjects */ err = device_rename(&dev->dev, dev->name); WARN_ON(err); /* Add the device back in the hashes */ list_netdevice(dev); /* Notify protocols, that a new device appeared. */ call_netdevice_notifiers(NETDEV_REGISTER, dev); /* * Prevent userspace races by waiting until the network * device is fully setup before sending notifications. */ rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U, GFP_KERNEL); synchronize_net(); err = 0; out: return err;
Safe
[]
linux
7bced397510ab569d31de4c70b39e13355046387
7.101645303267323e+37
104
net_dma: simple removal Per commit "77873803363c net_dma: mark broken" net_dma is no longer used and there is no plan to fix it. This is the mechanical removal of bits in CONFIG_NET_DMA ifdef guards. Reverting the remainder of the net_dma induced changes is deferred to subsequent patches. Marked for stable due to Roman's report of a memory leak in dma_pin_iovec_pages(): https://lkml.org/lkml/2014/9/3/177 Cc: Dave Jiang <dave.jiang@intel.com> Cc: Vinod Koul <vinod.koul@intel.com> Cc: David Whipple <whipple@securedatainnovations.ch> Cc: Alexander Duyck <alexander.h.duyck@intel.com> Cc: <stable@vger.kernel.org> Reported-by: Roman Gushchin <klamm@yandex-team.ru> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
0
int ext4_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { handle_t *handle = ext4_journal_current_handle(); int ret = 0, started = 0; unsigned max_blocks = bh_result->b_size >> inode->i_blkbits; int dio_credits; if (create && !handle) { /* Direct IO write... */ if (max_blocks > DIO_MAX_BLOCKS) max_blocks = DIO_MAX_BLOCKS; dio_credits = ext4_chunk_trans_blocks(inode, max_blocks); handle = ext4_journal_start(inode, dio_credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); goto out; } started = 1; } ret = ext4_get_blocks(handle, inode, iblock, max_blocks, bh_result, create ? EXT4_GET_BLOCKS_CREATE : 0); if (ret > 0) { bh_result->b_size = (ret << inode->i_blkbits); ret = 0; } if (started) ext4_journal_stop(handle); out: return ret; }
Safe
[ "CWE-703" ]
linux
744692dc059845b2a3022119871846e74d4f6e11
3.3021599461748345e+38
32
ext4: use ext4_get_block_write in buffer write Allocate uninitialized extent before ext4 buffer write and convert the extent to initialized after io completes. The purpose is to make sure an extent can only be marked initialized after it has been written with new data so we can safely drop the i_mutex lock in ext4 DIO read without exposing stale data. This helps to improve multi-thread DIO read performance on high-speed disks. Skip the nobh and data=journal mount cases to make things simple for now. Signed-off-by: Jiaying Zhang <jiayingz@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
0
static int send_msg(int sd, char *msg) { int n = 0; int l; if (!msg) { err: ERR(EINVAL, "Missing argument to send_msg()"); return 1; } l = strlen(msg); if (l <= 0) goto err; while (n < l) { int result = send(sd, msg + n, l, 0); if (result < 0) { ERR(errno, "Failed sending message to client"); return 1; } n += result; } DBG("Sent: %s%s", is_cont(msg) ? "\n" : "", msg); return 0; }
Safe
[ "CWE-120", "CWE-787" ]
uftpd
0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd
2.1441057990273163e+38
30
FTP: Fix buffer overflow in PORT parser, reported by Aaron Esau Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
0
jas_stream_t *jas_stream_fopen(const char *filename, const char *mode) { jas_stream_t *stream; jas_stream_fileobj_t *obj; int openflags; /* Allocate a stream object. */ if (!(stream = jas_stream_create())) { return 0; } /* Parse the mode string. */ stream->openmode_ = jas_strtoopenmode(mode); /* Determine the correct flags to use for opening the file. */ if ((stream->openmode_ & JAS_STREAM_READ) && (stream->openmode_ & JAS_STREAM_WRITE)) { openflags = O_RDWR; } else if (stream->openmode_ & JAS_STREAM_READ) { openflags = O_RDONLY; } else if (stream->openmode_ & JAS_STREAM_WRITE) { openflags = O_WRONLY; } else { openflags = 0; } if (stream->openmode_ & JAS_STREAM_APPEND) { openflags |= O_APPEND; } if (stream->openmode_ & JAS_STREAM_BINARY) { openflags |= O_BINARY; } if (stream->openmode_ & JAS_STREAM_CREATE) { openflags |= O_CREAT | O_TRUNC; } /* Allocate space for the underlying file stream object. */ if (!(obj = jas_malloc(sizeof(jas_stream_fileobj_t)))) { jas_stream_destroy(stream); return 0; } obj->fd = -1; obj->flags = 0; obj->pathname[0] = '\0'; stream->obj_ = (void *) obj; /* Select the operations for a file stream object. */ stream->ops_ = &jas_stream_fileops; /* Open the underlying file. */ if ((obj->fd = open(filename, openflags, JAS_STREAM_PERMS)) < 0) { // Free the underlying file object, since it will not otherwise // be freed. jas_free(obj); jas_stream_destroy(stream); return 0; } /* By default, use full buffering for this type of stream. */ jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0); return stream; }
Safe
[ "CWE-415", "CWE-190", "CWE-369" ]
jasper
634ce8e8a5accc0fa05dd2c20d42b4749d4b2735
3.1551591770726023e+38
62
Made some changes to the I/O stream library for memory streams. There were a number of potential problems due to the possibility of integer overflow. Changed some integral types to the larger types size_t or ssize_t. For example, the function mem_resize now takes the buffer size parameter as a size_t. Added a new function jas_stream_memopen2, which takes a buffer size specified as a size_t instead of an int. This can be used in jas_image_cmpt_create to avoid potential overflow problems. Added a new function jas_deprecated to warn about reliance on deprecated library behavior.
0
static int handle_invlpg(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { u64 exit_qualification = vmcs_read64(EXIT_QUALIFICATION); kvm_mmu_invlpg(vcpu, exit_qualification); skip_emulated_instruction(vcpu); return 1; }
Safe
[ "CWE-20" ]
linux-2.6
16175a796d061833aacfbd9672235f2d2725df65
2.0319555768501206e+38
8
KVM: VMX: Don't allow uninhibited access to EFER on i386 vmx_set_msr() does not allow i386 guests to touch EFER, but they can still do so through the default: label in the switch. If they set EFER_LME, they can oops the host. Fix by having EFER access through the normal channel (which will check for EFER_LME) even on i386. Reported-and-tested-by: Benjamin Gilbert <bgilbert@cs.cmu.edu> Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com>
0
static int handle_apic_access(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { u64 exit_qualification; enum emulation_result er; unsigned long offset; exit_qualification = vmcs_read64(EXIT_QUALIFICATION); offset = exit_qualification & 0xffful; er = emulate_instruction(vcpu, kvm_run, 0, 0, 0); if (er != EMULATE_DONE) { printk(KERN_ERR "Fail to handle apic access vmexit! Offset is 0x%lx\n", offset); return -ENOTSUPP; } return 1; }
Safe
[ "CWE-20" ]
linux-2.6
16175a796d061833aacfbd9672235f2d2725df65
2.757989679824596e+38
19
KVM: VMX: Don't allow uninhibited access to EFER on i386 vmx_set_msr() does not allow i386 guests to touch EFER, but they can still do so through the default: label in the switch. If they set EFER_LME, they can oops the host. Fix by having EFER access through the normal channel (which will check for EFER_LME) even on i386. Reported-and-tested-by: Benjamin Gilbert <bgilbert@cs.cmu.edu> Cc: stable@kernel.org Signed-off-by: Avi Kivity <avi@redhat.com>
0
void aes_crypt_ecb( aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16] ) { int i; unsigned long *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3; #if defined(XYSSL_PADLOCK_C) && defined(XYSSL_HAVE_X86) if( padlock_supports( PADLOCK_ACE ) ) { if( padlock_xcryptecb( ctx, mode, input, output ) == 0 ) return; } #endif if (ctx == NULL || ctx->rk == NULL) return; RK = ctx->rk; GET_ULONG_LE( X0, input, 0 ); X0 ^= *RK++; GET_ULONG_LE( X1, input, 4 ); X1 ^= *RK++; GET_ULONG_LE( X2, input, 8 ); X2 ^= *RK++; GET_ULONG_LE( X3, input, 12 ); X3 ^= *RK++; if( mode == AES_DECRYPT ) { for( i = (ctx->nr >> 1) - 1; i > 0; i-- ) { AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); } AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); X0 = *RK++ ^ ( RSb[ ( Y0 ) & 0xFF ] ) ^ ( RSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)RSb[ ( Y1 >> 24 ) & 0xFF ]) << 24 ); X1 = *RK++ ^ ( RSb[ ( Y1 ) & 0xFF ] ) ^ ( RSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)RSb[ ( Y2 >> 24 ) & 0xFF ]) << 24 ); X2 = *RK++ ^ ( RSb[ ( Y2 ) & 0xFF ] ) ^ ( RSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)RSb[ ( Y3 >> 24 ) & 0xFF ]) << 24 ); X3 = *RK++ ^ ( RSb[ ( Y3 ) & 0xFF ] ) ^ ( RSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)RSb[ ( Y0 >> 24 ) & 0xFF ]) << 24 ); } else /* AES_ENCRYPT */ { for( i = (ctx->nr >> 1) - 1; i > 0; i-- ) { AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); } AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); X0 = *RK++ ^ ( FSb[ ( Y0 ) & 0xFF ] ) ^ ( FSb[ ( Y1 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb[ ( Y2 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)FSb[ ( Y3 >> 24 ) & 0xFF ]) << 24 ); X1 = *RK++ ^ ( FSb[ ( Y1 ) & 0xFF ] ) ^ ( FSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb[ ( Y3 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)FSb[ ( Y0 >> 24 ) & 0xFF ]) << 24 ); X2 = *RK++ ^ ( FSb[ ( Y2 ) & 0xFF ] ) ^ ( FSb[ ( Y3 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)FSb[ ( Y1 >> 24 ) & 0xFF ]) << 24 ); X3 = *RK++ ^ ( FSb[ ( Y3 ) & 0xFF ] ) ^ ( FSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( ((unsigned int)FSb[ ( Y2 >> 24 ) & 0xFF ]) << 24 ); } PUT_ULONG_LE( X0, output, 0 ); PUT_ULONG_LE( X1, output, 4 ); PUT_ULONG_LE( X2, output, 8 ); PUT_ULONG_LE( X3, output, 12 ); }
Safe
[]
ghostpdl
8e9ce5016db968b40e4ec255a3005f2786cce45f
1.5147919458681672e+38
92
Bug 699665 "memory corruption in aesdecode" The specimen file calls aesdecode without specifying the key to be used, though it does manage to do enough work with the PDF interpreter routines to get access to aesdecode (which isn't normally available). This causes us to read uninitialised memory, which can (and often does) lead to a segmentation fault. In this commit we set the key to NULL explicitly during intialisation and then check it before we read it. If its NULL we just return. It seems bizarre that we don't return error codes, we should probably look into that at some point, but this prevents the code trying to read uninitialised memory.
0
static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int size, layout; int32_t yaw, pitch, roll; uint32_t l = 0, t = 0, r = 0, b = 0; uint32_t tag, padding = 0; enum AVSphericalProjection projection; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams - 1]; sc = st->priv_data; if (atom.size < 8) { av_log(c->fc, AV_LOG_ERROR, "Empty spherical video box\n"); return AVERROR_INVALIDDATA; } size = avio_rb32(pb); if (size <= 12 || size > atom.size) return AVERROR_INVALIDDATA; tag = avio_rl32(pb); if (tag != MKTAG('s','v','h','d')) { av_log(c->fc, AV_LOG_ERROR, "Missing spherical video header\n"); return 0; } avio_skip(pb, 4); /* version + flags */ avio_skip(pb, size - 12); /* metadata_source */ size = avio_rb32(pb); if (size > atom.size) return AVERROR_INVALIDDATA; tag = avio_rl32(pb); if (tag != MKTAG('p','r','o','j')) { av_log(c->fc, AV_LOG_ERROR, "Missing projection box\n"); return 0; } size = avio_rb32(pb); if (size > atom.size) return AVERROR_INVALIDDATA; tag = avio_rl32(pb); if (tag != MKTAG('p','r','h','d')) { av_log(c->fc, AV_LOG_ERROR, "Missing projection header box\n"); return 0; } avio_skip(pb, 4); /* version + flags */ /* 16.16 fixed point */ yaw = avio_rb32(pb); pitch = avio_rb32(pb); roll = avio_rb32(pb); size = avio_rb32(pb); if (size > atom.size) return AVERROR_INVALIDDATA; tag = avio_rl32(pb); avio_skip(pb, 4); /* version + flags */ switch (tag) { case MKTAG('c','b','m','p'): layout = avio_rb32(pb); if (layout) { av_log(c->fc, AV_LOG_WARNING, "Unsupported cubemap layout %d\n", layout); return 0; } projection = AV_SPHERICAL_CUBEMAP; padding = avio_rb32(pb); break; case MKTAG('e','q','u','i'): t = avio_rb32(pb); b = avio_rb32(pb); l = avio_rb32(pb); r = avio_rb32(pb); if (b >= UINT_MAX - t || r >= UINT_MAX - l) { av_log(c->fc, AV_LOG_ERROR, "Invalid bounding rectangle coordinates " "%"PRIu32",%"PRIu32",%"PRIu32",%"PRIu32"\n", l, t, r, b); return AVERROR_INVALIDDATA; } if (l || t || r || b) projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE; else projection = AV_SPHERICAL_EQUIRECTANGULAR; break; default: av_log(c->fc, AV_LOG_ERROR, "Unknown projection type\n"); return 0; } sc->spherical = av_spherical_alloc(&sc->spherical_size); if (!sc->spherical) return AVERROR(ENOMEM); sc->spherical->projection = projection; sc->spherical->yaw = yaw; sc->spherical->pitch = pitch; sc->spherical->roll = roll; sc->spherical->padding = padding; sc->spherical->bound_left = l; sc->spherical->bound_top = t; sc->spherical->bound_right = r; sc->spherical->bound_bottom = b; return 0; }
Safe
[ "CWE-399", "CWE-834" ]
FFmpeg
9cb4eb772839c5e1de2855d126bf74ff16d13382
2.380060147138742e+38
118
avformat/mov: Fix DoS in read_tfra() Fixes: Missing EOF check in loop No testcase Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
0
static int smack_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) { char **rule = (char **)vrule; *rule = NULL; if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) return -EINVAL; if (op != Audit_equal && op != Audit_not_equal) return -EINVAL; *rule = smk_import(rulestr, 0); return 0; }
Safe
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
2.262224040123226e+38
15
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
0
TEST(FormatterTest, FormatIntLocale) { ScopedMock<LocaleMock> mock; lconv lc = lconv(); char sep[] = "--"; lc.thousands_sep = sep; EXPECT_CALL(mock, localeconv()).Times(3).WillRepeatedly(testing::Return(&lc)); EXPECT_EQ("123", format("{:n}", 123)); EXPECT_EQ("1--234", format("{:n}", 1234)); EXPECT_EQ("1--234--567", format("{:n}", 1234567)); }
Safe
[ "CWE-134", "CWE-119", "CWE-787" ]
fmt
8cf30aa2be256eba07bb1cefb998c52326e846e7
3.958453080189265e+37
10
Fix segfault on complex pointer formatting (#642)
0
void MsgSetMSGoffs(msg_t *pMsg, short offs) { ISOBJ_TYPE_assert(pMsg, msg); pMsg->offMSG = offs; if(offs > pMsg->iLenRawMsg) { assert(offs - 1 == pMsg->iLenRawMsg); pMsg->iLenMSG = 0; } else { pMsg->iLenMSG = pMsg->iLenRawMsg - offs; } }
Safe
[ "CWE-772" ]
rsyslog
8083bd1433449fd2b1b79bf759f782e0f64c0cd2
3.2003684484930748e+38
11
backporting abort condition fix from 5.7.7
0
static void yam_tx_byte(struct net_device *dev, struct yam_port *yp) { struct sk_buff *skb; unsigned char b, temp; switch (yp->tx_state) { case TX_OFF: break; case TX_HEAD: if (--yp->tx_count <= 0) { if (!(skb = skb_dequeue(&yp->send_queue))) { ptt_off(dev); yp->tx_state = TX_OFF; break; } yp->tx_state = TX_DATA; if (skb->data[0] != 0) { /* do_kiss_params(s, skb->data, skb->len); */ dev_kfree_skb_any(skb); break; } yp->tx_len = skb->len - 1; /* strip KISS byte */ if (yp->tx_len >= YAM_MAX_FRAME || yp->tx_len < 2) { dev_kfree_skb_any(skb); break; } skb_copy_from_linear_data_offset(skb, 1, yp->tx_buf, yp->tx_len); dev_kfree_skb_any(skb); yp->tx_count = 0; yp->tx_crcl = 0x21; yp->tx_crch = 0xf3; yp->tx_state = TX_DATA; } break; case TX_DATA: b = yp->tx_buf[yp->tx_count++]; outb(b, THR(dev->base_addr)); temp = yp->tx_crcl; yp->tx_crcl = chktabl[temp] ^ yp->tx_crch; yp->tx_crch = chktabh[temp] ^ b; if (yp->tx_count >= yp->tx_len) { yp->tx_state = TX_CRC1; } break; case TX_CRC1: yp->tx_crch = chktabl[yp->tx_crcl] ^ yp->tx_crch; yp->tx_crcl = chktabh[yp->tx_crcl] ^ chktabl[yp->tx_crch] ^ 0xff; outb(yp->tx_crcl, THR(dev->base_addr)); yp->tx_state = TX_CRC2; break; case TX_CRC2: outb(chktabh[yp->tx_crch] ^ 0xFF, THR(dev->base_addr)); if (skb_queue_empty(&yp->send_queue)) { yp->tx_count = (yp->bitrate * yp->txtail) / 8000; if (yp->dupmode == 2) yp->tx_count += (yp->bitrate * yp->holdd) / 8; if (yp->tx_count == 0) yp->tx_count = 1; yp->tx_state = TX_TAIL; } else { yp->tx_count = 1; yp->tx_state = TX_HEAD; } ++dev->stats.tx_packets; break; case TX_TAIL: if (--yp->tx_count <= 0) { yp->tx_state = TX_OFF; ptt_off(dev); } break; } }
Safe
[ "CWE-399" ]
linux
8e3fbf870481eb53b2d3a322d1fc395ad8b367ed
3.0178044589037466e+38
75
hamradio/yam: fix info leak in ioctl The yam_ioctl() code fails to initialise the cmd field of the struct yamdrv_ioctl_cfg. Add an explicit memset(0) before filling the structure to avoid the 4-byte info leak. Signed-off-by: Salva Peiró <speiro@ai2.upv.es> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static int snd_ctl_elem_read_user(struct snd_card *card, struct snd_ctl_elem_value __user *_control) { struct snd_ctl_elem_value *control; int result; control = memdup_user(_control, sizeof(*control)); if (IS_ERR(control)) return PTR_ERR(control); down_read(&card->controls_rwsem); result = snd_ctl_elem_read(card, control); up_read(&card->controls_rwsem); if (result < 0) goto error; if (copy_to_user(_control, control, sizeof(*control))) result = -EFAULT; error: kfree(control); return result; }
Safe
[ "CWE-416", "CWE-125" ]
linux
6ab55ec0a938c7f943a4edba3d6514f775983887
2.303954845279247e+38
22
ALSA: control: Fix an out-of-bounds bug in get_ctl_id_hash() Since the user can control the arguments provided to the kernel by the ioctl() system call, an out-of-bounds bug occurs when the 'id->name' provided by the user does not end with '\0'. The following log can reveal it: [ 10.002313] BUG: KASAN: stack-out-of-bounds in snd_ctl_find_id+0x36c/0x3a0 [ 10.002895] Read of size 1 at addr ffff888109f5fe28 by task snd/439 [ 10.004934] Call Trace: [ 10.007140] snd_ctl_find_id+0x36c/0x3a0 [ 10.007489] snd_ctl_ioctl+0x6cf/0x10e0 Fix this by checking the bound of 'id->name' in the loop. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Link: https://lore.kernel.org/r/20220824081654.3767739-1-zheyuma97@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
0
virtual void visit(const messages::result_message::schema_change& m) override { auto change = m.get_change(); switch (change->type) { case event::event_type::SCHEMA_CHANGE: { auto sc = static_pointer_cast<event::schema_change>(change); _response.write_int(0x0005); _response.serialize(*sc, _version); break; } default: assert(0); } }
Safe
[]
scylladb
1c2eef384da439b0457b6d71c7e37d7268e471cb
2.724573749603575e+38
13
transport/server.cc: Return correct size of decompressed lz4 buffer An incorrect size is returned from the function, which could lead to crashes or undefined behavior. Fix by erroring out in these cases. Fixes #11476
0
static void gs_charEvent(struct fvcontainer *fvc,void *event) { struct gsd *gs = (struct gsd *) fvc; FVChar(gs->fv,event); }
Safe
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
4.18190536065929e+37
4
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
0
struct trace_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *key) { struct trace_buffer *buffer; long nr_pages; int bsize; int cpu; int ret; /* keep it in its own cache line */ buffer = kzalloc(ALIGN(sizeof(*buffer), cache_line_size()), GFP_KERNEL); if (!buffer) return NULL; if (!zalloc_cpumask_var(&buffer->cpumask, GFP_KERNEL)) goto fail_free_buffer; nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE); buffer->flags = flags; buffer->clock = trace_clock_local; buffer->reader_lock_key = key; init_irq_work(&buffer->irq_work.work, rb_wake_up_waiters); init_waitqueue_head(&buffer->irq_work.waiters); /* need at least two pages */ if (nr_pages < 2) nr_pages = 2; buffer->cpus = nr_cpu_ids; bsize = sizeof(void *) * nr_cpu_ids; buffer->buffers = kzalloc(ALIGN(bsize, cache_line_size()), GFP_KERNEL); if (!buffer->buffers) goto fail_free_cpumask; cpu = raw_smp_processor_id(); cpumask_set_cpu(cpu, buffer->cpumask); buffer->buffers[cpu] = rb_allocate_cpu_buffer(buffer, nr_pages, cpu); if (!buffer->buffers[cpu]) goto fail_free_buffers; ret = cpuhp_state_add_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node); if (ret < 0) goto fail_free_buffers; mutex_init(&buffer->mutex); return buffer; fail_free_buffers: for_each_buffer_cpu(buffer, cpu) { if (buffer->buffers[cpu]) rb_free_cpu_buffer(buffer->buffers[cpu]); } kfree(buffer->buffers); fail_free_cpumask: free_cpumask_var(buffer->cpumask); fail_free_buffer: kfree(buffer); return NULL; }
Safe
[ "CWE-362" ]
linux
bbeb97464eefc65f506084fd9f18f21653e01137
3.1355178314340832e+38
66
tracing: Fix race in trace_open and buffer resize call Below race can come, if trace_open and resize of cpu buffer is running parallely on different cpus CPUX CPUY ring_buffer_resize atomic_read(&buffer->resize_disabled) tracing_open tracing_reset_online_cpus ring_buffer_reset_cpu rb_reset_cpu rb_update_pages remove/insert pages resetting pointer This race can cause data abort or some times infinte loop in rb_remove_pages and rb_insert_pages while checking pages for sanity. Take buffer lock to fix this. Link: https://lkml.kernel.org/r/1601976833-24377-1-git-send-email-gkohli@codeaurora.org Cc: stable@vger.kernel.org Fixes: b23d7a5f4a07a ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU") Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
0
static int pfkey_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, int flags) { struct sock *sk = sock->sk; struct pfkey_sock *pfk = pfkey_sk(sk); struct sk_buff *skb; int copied, err; err = -EINVAL; if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT)) goto out; skb = skb_recv_datagram(sk, flags, &err); if (skb == NULL) goto out; copied = skb->len; if (copied > len) { msg->msg_flags |= MSG_TRUNC; copied = len; } skb_reset_transport_header(skb); err = skb_copy_datagram_msg(skb, 0, msg, copied); if (err) goto out_free; sock_recv_cmsgs(msg, sk, skb); err = (flags & MSG_TRUNC) ? skb->len : copied; if (pfk->dump.dump != NULL && 3 * atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf) pfkey_do_dump(pfk); out_free: skb_free_datagram(sk, skb); out: return err; }
Safe
[ "CWE-362" ]
linux
ba953a9d89a00c078b85f4b190bc1dde66fe16b5
5.553525137556928e+37
40
af_key: Do not call xfrm_probe_algs in parallel When namespace support was added to xfrm/afkey, it caused the previously single-threaded call to xfrm_probe_algs to become multi-threaded. This is buggy and needs to be fixed with a mutex. Reported-by: Abhishek Shah <abhishek.shah@columbia.edu> Fixes: 283bc9f35bbb ("xfrm: Namespacify xfrm state/policy locks") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
0
f_getcurpos(typval_T *argvars, typval_T *rettv) { getpos_both(argvars, rettv, TRUE); }
Safe
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
3.1398047689083006e+38
4
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
0
str_equal (const char *a, const char *b, gboolean insensitive) { if (a == NULL || b == NULL) return a == b; return insensitive ? !g_ascii_strcasecmp (a, b) : !strcmp (a, b); }
Safe
[]
gvfs
f81ff2108ab3b6e370f20dcadd8708d23f499184
9.030760744257874e+37
7
dav: don't unescape the uri twice path_equal tries to unescape path before comparing. Unfortunately this function is used also for already unescaped paths. Therefore unescaping can fail. This commit reverts changes which was done in commit 50af53d and unescape just uris, which aren't unescaped yet. https://bugzilla.gnome.org/show_bug.cgi?id=743298
0
static int check_host (X509 *x509cert, const char *hostname, char *err, size_t errlen) { int i, rc = 0; /* hostname in ASCII format: */ char *hostname_ascii = NULL; /* needed to get the common name: */ X509_NAME *x509_subject; char *buf = NULL; int bufsize; /* needed to get the DNS subjectAltNames: */ STACK_OF(GENERAL_NAME) *subj_alt_names; int subj_alt_names_count; GENERAL_NAME *subj_alt_name; /* did we find a name matching hostname? */ int match_found; /* Check if 'hostname' matches the one of the subjectAltName extensions of * type DNS or the Common Name (CN). */ #if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) if (idna_to_ascii_lz(hostname, &hostname_ascii, 0) != IDNA_SUCCESS) { hostname_ascii = safe_strdup(hostname); } #else hostname_ascii = safe_strdup(hostname); #endif /* Try the DNS subjectAltNames. */ match_found = 0; if ((subj_alt_names = X509_get_ext_d2i(x509cert, NID_subject_alt_name, NULL, NULL))) { subj_alt_names_count = sk_GENERAL_NAME_num(subj_alt_names); for (i = 0; i < subj_alt_names_count; i++) { subj_alt_name = sk_GENERAL_NAME_value(subj_alt_names, i); if (subj_alt_name->type == GEN_DNS) { if (subj_alt_name->d.ia5->length >= 0 && mutt_strlen((char *)subj_alt_name->d.ia5->data) == (size_t)subj_alt_name->d.ia5->length && (match_found = hostname_match(hostname_ascii, (char *)(subj_alt_name->d.ia5->data)))) { break; } } } GENERAL_NAMES_free(subj_alt_names); } if (!match_found) { /* Try the common name */ if (!(x509_subject = X509_get_subject_name(x509cert))) { if (err && errlen) strfcpy (err, _("cannot get certificate subject"), errlen); goto out; } /* first get the space requirements */ bufsize = X509_NAME_get_text_by_NID(x509_subject, NID_commonName, NULL, 0); if (bufsize == -1) { if (err && errlen) strfcpy (err, _("cannot get certificate common name"), errlen); goto out; } bufsize++; /* space for the terminal nul char */ buf = safe_malloc((size_t)bufsize); if (X509_NAME_get_text_by_NID(x509_subject, NID_commonName, buf, bufsize) == -1) { if (err && errlen) strfcpy (err, _("cannot get certificate common name"), errlen); goto out; } /* cast is safe since bufsize is incremented above, so bufsize-1 is always * zero or greater. */ if (mutt_strlen(buf) == (size_t)bufsize - 1) { match_found = hostname_match(hostname_ascii, buf); } } if (!match_found) { if (err && errlen) snprintf (err, errlen, _("certificate owner does not match hostname %s"), hostname); goto out; } rc = 1; out: FREE(&buf); FREE(&hostname_ascii); return rc; }
Safe
[ "CWE-74" ]
mutt
c547433cdf2e79191b15c6932c57f1472bfb5ff4
1.2879370036722298e+38
104
Fix STARTTLS response injection attack. Thanks again to Damian Poddebniak and Fabian Ising from the Münster University of Applied Sciences for reporting this issue. Their summary in ticket 248 states the issue clearly: We found another STARTTLS-related issue in Mutt. Unfortunately, it affects SMTP, POP3 and IMAP. When the server responds with its "let's do TLS now message", e.g. A OK begin TLS\r\n in IMAP or +OK begin TLS\r\n in POP3, Mutt will also read any data after the \r\n and save it into some internal buffer for later processing. This is problematic, because a MITM attacker can inject arbitrary responses. There is a nice blogpost by Wietse Venema about a "command injection" in postfix (http://www.postfix.org/CVE-2011-0411.html). What we have here is the problem in reverse, i.e. not a command injection, but a "response injection." This commit fixes the issue by clearing the CONNECTION input buffer in mutt_ssl_starttls(). To make backporting this fix easier, the new functions only clear the top-level CONNECTION buffer; they don't handle nested buffering in mutt_zstrm.c or mutt_sasl.c. However both of those wrap the connection *after* STARTTLS, so this is currently okay. mutt_tunnel.c occurs before connecting, but it does not perform any nesting.
0
query_async_data_free (QueryAsyncData *self) { if (self->domain != NULL) g_object_unref (self->domain); g_free (self->feed_uri); if (self->query) g_object_unref (self->query); if (self->feed) g_object_unref (self->feed); g_slice_free (QueryAsyncData, self); }
Safe
[ "CWE-20" ]
libgdata
6799f2c525a584dc998821a6ce897e463dad7840
2.9050635138217237e+38
13
core: Validate SSL certificates for all connections This prevents MitM attacks which use spoofed SSL certificates. Note that this bumps our libsoup requirement to 2.37.91. Closes: https://bugzilla.gnome.org/show_bug.cgi?id=671535
0
static int check_ld_abs(struct verifier_env *env, struct bpf_insn *insn) { struct reg_state *regs = env->cur_state.regs; u8 mode = BPF_MODE(insn->code); struct reg_state *reg; int i, err; if (!may_access_skb(env->prog->type)) { verbose("BPF_LD_ABS|IND instructions not allowed for this program type\n"); return -EINVAL; } if (insn->dst_reg != BPF_REG_0 || insn->off != 0 || BPF_SIZE(insn->code) == BPF_DW || (mode == BPF_ABS && insn->src_reg != BPF_REG_0)) { verbose("BPF_LD_ABS uses reserved fields\n"); return -EINVAL; } /* check whether implicit source operand (register R6) is readable */ err = check_reg_arg(regs, BPF_REG_6, SRC_OP); if (err) return err; if (regs[BPF_REG_6].type != PTR_TO_CTX) { verbose("at the time of BPF_LD_ABS|IND R6 != pointer to skb\n"); return -EINVAL; } if (mode == BPF_IND) { /* check explicit source operand */ err = check_reg_arg(regs, insn->src_reg, SRC_OP); if (err) return err; } /* reset caller saved regs to unreadable */ for (i = 0; i < CALLER_SAVED_REGS; i++) { reg = regs + caller_saved[i]; reg->type = NOT_INIT; reg->imm = 0; } /* mark destination R0 register as readable, since it contains * the value fetched from the packet */ regs[BPF_REG_0].type = UNKNOWN_VALUE; return 0; }
Safe
[ "CWE-703" ]
linux
92117d8443bc5afacc8d5ba82e541946310f106e
1.2063013571187427e+38
49
bpf: fix refcnt overflow On a system with >32Gbyte of phyiscal memory and infinite RLIMIT_MEMLOCK, the malicious application may overflow 32-bit bpf program refcnt. It's also possible to overflow map refcnt on 1Tb system. Impose 32k hard limit which means that the same bpf program or map cannot be shared by more than 32k processes. Fixes: 1be7f75d1668 ("bpf: enable non-root eBPF programs") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static void portio_release(struct kobject *kobj) { struct uio_portio *portio = to_portio(kobj); kfree(portio); }
Safe
[ "CWE-119", "CWE-189", "CWE-703" ]
linux
7314e613d5ff9f0934f7a0f74ed7973b903315d1
1.2426533801564437e+38
5
Fix a few incorrectly checked [io_]remap_pfn_range() calls Nico Golde reports a few straggling uses of [io_]remap_pfn_range() that really should use the vm_iomap_memory() helper. This trivially converts two of them to the helper, and comments about why the third one really needs to continue to use remap_pfn_range(), and adds the missing size check. Reported-by: Nico Golde <nico@ngolde.de> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org.
0
static struct crypto_aead *macsec_alloc_tfm(char *key, int key_len, int icv_len) { struct crypto_aead *tfm; int ret; tfm = crypto_alloc_aead("gcm(aes)", 0, 0); if (IS_ERR(tfm)) return tfm; ret = crypto_aead_setkey(tfm, key, key_len); if (ret < 0) goto fail; ret = crypto_aead_setauthsize(tfm, icv_len); if (ret < 0) goto fail; return tfm; fail: crypto_free_aead(tfm); return ERR_PTR(ret); }
Safe
[ "CWE-119" ]
net
5294b83086cc1c35b4efeca03644cf9d12282e5b
1.7248716497983266e+38
23
macsec: dynamically allocate space for sglist We call skb_cow_data, which is good anyway to ensure we can actually modify the skb as such (another error from prior). Now that we have the number of fragments required, we can safely allocate exactly that amount of memory. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Acked-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
0
int blkid_partitions_strcpy_ptuuid(blkid_probe pr, char *str) { struct blkid_chain *chn = blkid_probe_get_chain(pr); if (chn->binary || !str || !*str) return 0; if (!blkid_probe_set_value(pr, "PTUUID", (unsigned char *) str, strlen(str) + 1)) return -ENOMEM; return 0; }
Safe
[]
util-linux
50d1594c2e6142a3b51d2143c74027480df082e0
2.8220033072362708e+38
12
libblkid: avoid non-empty recursion in EBR This is extension to the patch 7164a1c34d18831ac61c6744ad14ce916d389b3f. We also need to detect non-empty recursion in the EBR chain. It's possible to create standard valid logical partitions and in the last one points back to the EBR chain. In this case all offsets will be non-empty. Unfortunately, it's valid to create logical partitions that are not in the "disk order" (sorted by start offset). So link somewhere back is valid, but this link cannot points to already existing partition (otherwise we will see recursion). This patch forces libblkid to ignore duplicate logical partitions, the duplicate chain segment is interpreted as non-data segment, after 100 iterations with non-data segments it will break the loop -- no memory is allocated in this case by the loop. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536 References: http://seclists.org/oss-sec/2016/q3/40 Signed-off-by: Karel Zak <kzak@redhat.com>
0
qb_ipc_socket_send(struct qb_ipc_one_way *one_way, const void *msg_ptr, size_t msg_len) { ssize_t rc = 0; struct ipc_us_control *ctl; ctl = (struct ipc_us_control *)one_way->u.us.shared_data; if (one_way->u.us.sock_name) { rc = _finish_connecting(one_way); if (rc < 0) { qb_util_log(LOG_ERR, "socket connect-on-send"); return rc; } } qb_sigpipe_ctl(QB_SIGPIPE_IGNORE); rc = send(one_way->u.us.sock, msg_ptr, msg_len, MSG_NOSIGNAL); if (rc == -1) { rc = -errno; if (errno != EAGAIN && errno != ENOBUFS) { qb_util_perror(LOG_DEBUG, "socket_send:send"); } } qb_sigpipe_ctl(QB_SIGPIPE_DEFAULT); if (ctl && rc == msg_len) { qb_atomic_int_inc(&ctl->sent); } return rc; }
Safe
[ "CWE-59" ]
libqb
e322e98dc264bc5911d6fe1d371e55ac9f95a71e
2.2224781515938462e+38
31
ipc: use O_EXCL on SHM files, and randomize the names Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
0
txBoolean fxCheckLength(txMachine* the, txSlot* slot, txInteger* index) { txNumber number = fxToNumber(the, slot); txNumber check = c_trunc(number); if ((number == check) && (0 <= number) && (number <= 0x7FFFFFFF)) { *index = (txInteger)number; return 1 ; } return 0; }
Safe
[ "CWE-125" ]
moddable
135aa9a4a6a9b49b60aa730ebc3bcc6247d75c45
1.8103942333842957e+38
10
XS: #896
0
void StreamEncoderImpl::encodeHeader(const char* key, uint32_t key_size, const char* value, uint32_t value_size) { connection_.reserveBuffer(key_size + value_size + 4); ASSERT(key_size > 0); connection_.copyToBuffer(key, key_size); connection_.addCharToBuffer(':'); connection_.addCharToBuffer(' '); connection_.copyToBuffer(value, value_size); connection_.addCharToBuffer('\r'); connection_.addCharToBuffer('\n'); }
Safe
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
2.0322704072350447e+38
13
Track byteSize of HeaderMap internally. Introduces a cached byte size updated internally in HeaderMap. The value is stored as an optional, and is cleared whenever a non-const pointer or reference to a HeaderEntry is accessed. The cached value can be set with refreshByteSize() which performs an iteration over the HeaderMap to sum the size of each key and value in the HeaderMap. Signed-off-by: Asra Ali <asraa@google.com>
0
unshape_window (GSWindow *window) { gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)), NULL, 0, 0); }
Safe
[ "CWE-284" ]
cinnamon-screensaver
da7af55f1fa966c52e15cc288d4f8928eca8cc9f
3.1184265176631454e+38
7
Workaround gtk3 bug, don't allow GtkWindow to handle popup_menu.
0
bus_server_init (void) { GError *error = NULL; dbus = bus_dbus_impl_get_default (); ibus = bus_ibus_impl_get_default (); bus_dbus_impl_register_object (dbus, (IBusService *)ibus); /* init server */ GDBusServerFlags flags = G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS; gchar *guid = g_dbus_generate_guid (); if (!g_str_has_prefix (g_address, "unix:tmpdir=") && !g_str_has_prefix (g_address, "unix:path=")) { g_error ("Your socket address does not have the format unix:tmpdir=$DIR " "or unix:path=$FILE; %s", g_address); } server = g_dbus_server_new_sync ( g_address, /* the place where the socket file lives, e.g. /tmp, abstract namespace, etc. */ flags, guid, NULL /* observer */, NULL /* cancellable */, &error); if (server == NULL) { g_error ("g_dbus_server_new_sync() is failed with address %s " "and guid %s: %s", g_address, guid, error->message); } g_free (guid); g_signal_connect (server, "new-connection", G_CALLBACK (bus_new_connection_cb), NULL); g_dbus_server_start (server); address = g_strdup_printf ("%s,guid=%s", g_dbus_server_get_client_address (server), g_dbus_server_get_guid (server)); /* write address to file */ ibus_write_address (address); /* own a session bus name so that third parties can easily track our life-cycle */ g_bus_own_name (G_BUS_TYPE_SESSION, IBUS_SERVICE_IBUS, G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired_handler, NULL, NULL, NULL, NULL); }
Vulnerable
[ "CWE-862" ]
ibus
3d442dbf936d197aa11ca0a71663c2bc61696151
1.9190730038830173e+38
46
bus: Implement GDBusAuthObserver callback ibus uses a GDBusServer with G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS, and doesn't set a GDBusAuthObserver, which allows anyone who can connect to its AF_UNIX socket to authenticate and be authorized to send method calls. It also seems to use an abstract AF_UNIX socket, which does not have filesystem permissions, so the practical effect might be that a local attacker can connect to another user's ibus service and make arbitrary method calls. BUGS=rhbz#1717958
1
static void sdhci_sysbus_init(Object *obj) { SDHCIState *s = SYSBUS_SDHCI(obj); sdhci_initfn(s); }
Safe
[ "CWE-119" ]
qemu
dfba99f17feb6d4a129da19d38df1bcd8579d1c3
2.113386546198574e+38
6
hw/sd/sdhci: Fix DMA Transfer Block Size field The 'Transfer Block Size' field is 12-bit wide. See section '2.2.2. Block Size Register (Offset 004h)' in datasheet. Two different bug reproducer available: - https://bugs.launchpad.net/qemu/+bug/1892960 - https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Fsdhci_oob_write1 Cc: qemu-stable@nongnu.org Buglink: https://bugs.launchpad.net/qemu/+bug/1892960 Fixes: d7dfca0807a ("hw/sdhci: introduce standard SD host controller") Reported-by: Alexander Bulekov <alxndr@bu.edu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org> Tested-by: Alexander Bulekov <alxndr@bu.edu> Message-Id: <20200901140411.112150-3-f4bug@amsat.org>
0
static bool ok_inflater_distance_with_tree(ok_inflater *inflater, const ok_inflater_huffman_tree *tree) { if (inflater->state_count < 0) { inflater->state_count = ok_inflater_decode_length(inflater, inflater->huffman_code); if (inflater->state_count < 0) { // Needs input return false; } inflater->huffman_code = -1; } if (inflater->state_distance < 0) { inflater->state_distance = ok_inflater_decode_distance(inflater, tree); if (inflater->state_distance < 0) { // Needs input return false; } } // Copy len bytes from offset to buffer_end_pos int buffer_offset = (inflater->buffer_end_pos - inflater->state_distance) & BUFFER_SIZE_MASK; if (inflater->state_distance == 1) { // Optimization: can use memset int n = inflater->state_count; int n2 = ok_inflater_write_byte_n(inflater, inflater->buffer[buffer_offset], n); inflater->state_count -= n2; if (n2 != n) { // Full buffer return false; } } else if (buffer_offset + inflater->state_count < BUFFER_SIZE) { // Optimization: the offset won't wrap int bytes_copyable = inflater->state_distance; while (inflater->state_count > 0) { int n = min(inflater->state_count, bytes_copyable); int n2 = ok_inflater_write_bytes(inflater, inflater->buffer + buffer_offset, n); inflater->state_count -= n2; bytes_copyable += n2; if (n2 != n) { // Full buffer return false; } } } else { // This could be optimized, but it happens rarely, so it's probably not worth it while (inflater->state_count > 0) { int n = min(inflater->state_count, inflater->state_distance); n = min(n, (BUFFER_SIZE - buffer_offset)); int n2 = ok_inflater_write_bytes(inflater, inflater->buffer + buffer_offset, n); inflater->state_count -= n2; buffer_offset = (buffer_offset + n2) & BUFFER_SIZE_MASK; if (n2 != n) { // Full buffer return false; } } } return true; }
Safe
[ "CWE-787" ]
ok-file-formats
e49cdfb84fb5eca2a6261f3c51a3c793fab9f62e
2.6266288976944206e+38
58
ok_png: Disallow multiple IHDR chunks (#15)
0
void h2_beam_on_consumed(h2_bucket_beam *beam, h2_beam_ev_callback *ev_cb, h2_beam_io_callback *io_cb, void *ctx) { h2_beam_lock bl; if (enter_yellow(beam, &bl) == APR_SUCCESS) { beam->cons_ev_cb = ev_cb; beam->cons_io_cb = io_cb; beam->cons_ctx = ctx; leave_yellow(beam, &bl); } }
Safe
[ "CWE-400" ]
mod_h2
83a2e3866918ce6567a683eb4c660688d047ee81
1.3633186062662012e+38
12
* fixes a race condition where aborting streams triggers an unnecessary timeout.
0
static void __net_exit sit_exit_batch_net(struct list_head *net_list) { LIST_HEAD(list); struct net *net; rtnl_lock(); list_for_each_entry(net, net_list, exit_list) sit_destroy_tunnels(net, &list); unregister_netdevice_many(&list); rtnl_unlock(); }
Safe
[ "CWE-703", "CWE-772", "CWE-401" ]
linux
07f12b26e21ab359261bf75cfcb424fdc7daeb6d
1.597922020696749e+38
12
net: sit: fix memory leak in sit_init_net() If register_netdev() is failed to register sitn->fb_tunnel_dev, it will go to err_reg_dev and forget to free netdev(sitn->fb_tunnel_dev). BUG: memory leak unreferenced object 0xffff888378daad00 (size 512): comm "syz-executor.1", pid 4006, jiffies 4295121142 (age 16.115s) hex dump (first 32 bytes): 00 e6 ed c0 83 88 ff ff 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000d6dcb63e>] kvmalloc include/linux/mm.h:577 [inline] [<00000000d6dcb63e>] kvzalloc include/linux/mm.h:585 [inline] [<00000000d6dcb63e>] netif_alloc_netdev_queues net/core/dev.c:8380 [inline] [<00000000d6dcb63e>] alloc_netdev_mqs+0x600/0xcc0 net/core/dev.c:8970 [<00000000867e172f>] sit_init_net+0x295/0xa40 net/ipv6/sit.c:1848 [<00000000871019fa>] ops_init+0xad/0x3e0 net/core/net_namespace.c:129 [<00000000319507f6>] setup_net+0x2ba/0x690 net/core/net_namespace.c:314 [<0000000087db4f96>] copy_net_ns+0x1dc/0x330 net/core/net_namespace.c:437 [<0000000057efc651>] create_new_namespaces+0x382/0x730 kernel/nsproxy.c:107 [<00000000676f83de>] copy_namespaces+0x2ed/0x3d0 kernel/nsproxy.c:165 [<0000000030b74bac>] copy_process.part.27+0x231e/0x6db0 kernel/fork.c:1919 [<00000000fff78746>] copy_process kernel/fork.c:1713 [inline] [<00000000fff78746>] _do_fork+0x1bc/0xe90 kernel/fork.c:2224 [<000000001c2e0d1c>] do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290 [<00000000ec48bd44>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<0000000039acff8a>] 0xffffffffffffffff Signed-off-by: Mao Wenan <maowenan@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb, int ifindex, u16 family) { struct sock *sk = skb_to_full_sk(skb); struct sk_security_struct *sksec; struct common_audit_data ad; struct lsm_network_audit net = {0,}; char *addrp; u8 proto; if (sk == NULL) return NF_ACCEPT; sksec = sk->sk_security; ad.type = LSM_AUDIT_DATA_NET; ad.u.net = &net; ad.u.net->netif = ifindex; ad.u.net->family = family; if (selinux_parse_skb(skb, &ad, &addrp, 0, &proto)) return NF_DROP; if (selinux_secmark_enabled()) if (avc_has_perm(sksec->sid, skb->secmark, SECCLASS_PACKET, PACKET__SEND, &ad)) return NF_DROP_ERR(-ECONNREFUSED); if (selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto)) return NF_DROP_ERR(-ECONNREFUSED); return NF_ACCEPT; }
Safe
[ "CWE-682" ]
linux-stable
0c461cb727d146c9ef2d3e86214f498b78b7d125
1.8940170446630084e+38
32
selinux: fix off-by-one in setprocattr SELinux tries to support setting/clearing of /proc/pid/attr attributes from the shell by ignoring terminating newlines and treating an attribute value that begins with a NUL or newline as an attempt to clear the attribute. However, the test for clearing attributes has always been wrong; it has an off-by-one error, and this could further lead to reading past the end of the allocated buffer since commit bb646cdb12e75d82258c2f2e7746d5952d3e321a ("proc_pid_attr_write(): switch to memdup_user()"). Fix the off-by-one error. Even with this fix, setting and clearing /proc/pid/attr attributes from the shell is not straightforward since the interface does not support multiple write() calls (so shells that write the value and newline separately will set and then immediately clear the attribute, requiring use of echo -n to set the attribute), whereas trying to use echo -n "" to clear the attribute causes the shell to skip the write() call altogether since POSIX says that a zero-length write causes no side effects. Thus, one must use echo -n to set and echo without -n to clear, as in the following example: $ echo -n unconfined_u:object_r:user_home_t:s0 > /proc/$$/attr/fscreate $ cat /proc/$$/attr/fscreate unconfined_u:object_r:user_home_t:s0 $ echo "" > /proc/$$/attr/fscreate $ cat /proc/$$/attr/fscreate Note the use of /proc/$$ rather than /proc/self, as otherwise the cat command will read its own attribute value, not that of the shell. There are no users of this facility to my knowledge; possibly we should just get rid of it. UPDATE: Upon further investigation it appears that a local process with the process:setfscreate permission can cause a kernel panic as a result of this bug. This patch fixes CVE-2017-2618. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> [PM: added the update about CVE-2017-2618 to the commit description] Cc: stable@vger.kernel.org # 3.5: d6ea83ec6864e Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
0
static int manager_setup_user_lookup_fd(Manager *m) { int r; assert(m); /* Set up the socket pair used for passing UID/GID resolution results from forked off processes to PID * 1. Background: we can't do name lookups (NSS) from PID 1, since it might involve IPC and thus activation, * and we might hence deadlock on ourselves. Hence we do all user/group lookups asynchronously from the forked * off processes right before executing the binaries to start. In order to be able to clean up any IPC objects * created by a unit (see RemoveIPC=) we need to know in PID 1 the used UID/GID of the executed processes, * hence we establish this communication channel so that forked off processes can pass their UID/GID * information back to PID 1. The forked off processes send their resolved UID/GID to PID 1 in a simple * datagram, along with their unit name, so that we can share one communication socket pair among all units for * this purpose. * * You might wonder why we need a communication channel for this that is independent of the usual notification * socket scheme (i.e. $NOTIFY_SOCKET). The primary difference is about trust: data sent via the $NOTIFY_SOCKET * channel is only accepted if it originates from the right unit and if reception was enabled for it. The user * lookup socket OTOH is only accessible by PID 1 and its children until they exec(), and always available. * * Note that this function is called under two circumstances: when we first initialize (in which case we * allocate both the socket pair and the event source to listen on it), and when we deserialize after a reload * (in which case the socket pair already exists but we still need to allocate the event source for it). */ if (m->user_lookup_fds[0] < 0) { /* Free all secondary fields */ safe_close_pair(m->user_lookup_fds); m->user_lookup_event_source = sd_event_source_unref(m->user_lookup_event_source); if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, m->user_lookup_fds) < 0) return log_error_errno(errno, "Failed to allocate user lookup socket: %m"); (void) fd_inc_rcvbuf(m->user_lookup_fds[0], NOTIFY_RCVBUF_SIZE); } if (!m->user_lookup_event_source) { r = sd_event_add_io(m->event, &m->user_lookup_event_source, m->user_lookup_fds[0], EPOLLIN, manager_dispatch_user_lookup_fd, m); if (r < 0) return log_error_errno(errno, "Failed to allocate user lookup event source: %m"); /* Process even earlier than the notify event source, so that we always know first about valid UID/GID * resolutions */ r = sd_event_source_set_priority(m->user_lookup_event_source, SD_EVENT_PRIORITY_NORMAL-8); if (r < 0) return log_error_errno(errno, "Failed to set priority ot user lookup event source: %m"); (void) sd_event_source_set_description(m->user_lookup_event_source, "user-lookup"); } return 0; }
Safe
[ "CWE-20" ]
systemd
531ac2b2349da02acc9c382849758e07eb92b020
5.617013264078868e+37
52
If the notification message length is 0, ignore the message (#4237) Fixes #4234. Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
0
ar6000_close(struct net_device *dev) { struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev); netif_stop_queue(dev); ar6000_disconnect(ar); if(ar->arWmiReady == true) { if (wmi_scanparams_cmd(ar->arWmi, 0xFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0) != 0) { return -EIO; } ar->arWlanState = WLAN_DISABLED; } ar6k_cfg80211_scanComplete_event(ar, A_ECANCELED); return 0; }
Safe
[ "CWE-703", "CWE-264" ]
linux
550fd08c2cebad61c548def135f67aba284c6162
1.1330626390560444e+38
18
net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared After the last patch, We are left in a state in which only drivers calling ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real hardware call ether_setup for their net_devices and don't hold any state in their skbs. There are a handful of drivers that violate this assumption of course, and need to be fixed up. This patch identifies those drivers, and marks them as not being able to support the safe transmission of skbs by clearning the IFF_TX_SKB_SHARING flag in priv_flags Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Karsten Keil <isdn@linux-pingi.de> CC: "David S. Miller" <davem@davemloft.net> CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: Patrick McHardy <kaber@trash.net> CC: Krzysztof Halasa <khc@pm.waw.pl> CC: "John W. Linville" <linville@tuxdriver.com> CC: Greg Kroah-Hartman <gregkh@suse.de> CC: Marcel Holtmann <marcel@holtmann.org> CC: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static void *tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct tcp_iter_state *st = seq->private; void *rc = NULL; if (v == SEQ_START_TOKEN) { rc = tcp_get_idx(seq, 0); goto out; } switch (st->state) { case TCP_SEQ_STATE_OPENREQ: case TCP_SEQ_STATE_LISTENING: rc = listening_get_next(seq, v); if (!rc) { st->state = TCP_SEQ_STATE_ESTABLISHED; st->bucket = 0; st->offset = 0; rc = established_get_first(seq); } break; case TCP_SEQ_STATE_ESTABLISHED: case TCP_SEQ_STATE_TIME_WAIT: rc = established_get_next(seq, v); break; } out: ++*pos; st->last_pos = *pos; return rc; }
Safe
[ "CWE-362" ]
linux-2.6
f6d8bd051c391c1c0458a30b2a7abcd939329259
2.3392144230887726e+38
31
inet: add RCU protection to inet->opt We lack proper synchronization to manipulate inet->opt ip_options Problem is ip_make_skb() calls ip_setup_cork() and ip_setup_cork() possibly makes a copy of ipc->opt (struct ip_options), without any protection against another thread manipulating inet->opt. Another thread can change inet->opt pointer and free old one under us. Use RCU to protect inet->opt (changed to inet->inet_opt). Instead of handling atomic refcounts, just copy ip_options when necessary, to avoid cache line dirtying. We cant insert an rcu_head in struct ip_options since its included in skb->cb[], so this patch is large because I had to introduce a new ip_options_rcu structure. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
0
static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); }
Safe
[ "CWE-787" ]
stb
5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40
2.3783226211661913e+38
41
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.
0
static int hugetlb_acct_memory(struct hstate *h, long delta) { int ret = -ENOMEM; spin_lock(&hugetlb_lock); /* * When cpuset is configured, it breaks the strict hugetlb page * reservation as the accounting is done on a global variable. Such * reservation is completely rubbish in the presence of cpuset because * the reservation is not checked against page availability for the * current cpuset. Application can still potentially OOM'ed by kernel * with lack of free htlb page in cpuset that the task is in. * Attempt to enforce strict accounting with cpuset is almost * impossible (or too ugly) because cpuset is too fluid that * task or memory node can be dynamically moved between cpusets. * * The change of semantics for shared hugetlb mapping with cpuset is * undesirable. However, in order to preserve some of the semantics, * we fall back to check against current free page availability as * a best attempt and hopefully to minimize the impact of changing * semantics that cpuset has. * * Apart from cpuset, we also have memory policy mechanism that * also determines from which node the kernel will allocate memory * in a NUMA system. So similar to cpuset, we also should consider * the memory policy of the current task. Similar to the description * above. */ if (delta > 0) { if (gather_surplus_pages(h, delta) < 0) goto out; if (delta > allowed_mems_nr(h)) { return_unused_surplus_pages(h, delta); goto out; } } ret = 0; if (delta < 0) return_unused_surplus_pages(h, (unsigned long) -delta); out: spin_unlock(&hugetlb_lock); return ret; }
Safe
[ "CWE-362" ]
linux
17743798d81238ab13050e8e2833699b54e15467
2.049875336707915e+38
46
mm/hugetlb: fix a race between hugetlb sysctl handlers There is a race between the assignment of `table->data` and write value to the pointer of `table->data` in the __do_proc_doulongvec_minmax() on the other thread. CPU0: CPU1: proc_sys_write hugetlb_sysctl_handler proc_sys_call_handler hugetlb_sysctl_handler_common hugetlb_sysctl_handler table->data = &tmp; hugetlb_sysctl_handler_common table->data = &tmp; proc_doulongvec_minmax do_proc_doulongvec_minmax sysctl_head_finish __do_proc_doulongvec_minmax unuse_table i = table->data; *i = val; // corrupt CPU1's stack Fix this by duplicating the `table`, and only update the duplicate of it. And introduce a helper of proc_hugetlb_doulongvec_minmax() to simplify the code. The following oops was seen: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page Code: Bad RIP value. ... Call Trace: ? set_max_huge_pages+0x3da/0x4f0 ? alloc_pool_huge_page+0x150/0x150 ? proc_doulongvec_minmax+0x46/0x60 ? hugetlb_sysctl_handler_common+0x1c7/0x200 ? nr_hugepages_store+0x20/0x20 ? copy_fd_bitmaps+0x170/0x170 ? hugetlb_sysctl_handler+0x1e/0x20 ? proc_sys_call_handler+0x2f1/0x300 ? unregister_sysctl_table+0xb0/0xb0 ? __fd_install+0x78/0x100 ? proc_sys_write+0x14/0x20 ? __vfs_write+0x4d/0x90 ? vfs_write+0xef/0x240 ? ksys_write+0xc0/0x160 ? __ia32_sys_read+0x50/0x50 ? __close_fd+0x129/0x150 ? __x64_sys_write+0x43/0x50 ? do_syscall_64+0x6c/0x200 ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: e5ff215941d5 ("hugetlb: multiple hstates for multiple page sizes") Signed-off-by: Muchun Song <songmuchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/20200828031146.43035-1-songmuchun@bytedance.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
fill_input_buffer (j_decompress_ptr cinfo) { static uchar jpeg_buffer[4096]; size_t nbytes; nbytes = fread (jpeg_buffer, 1, 4096, ifp); swab (jpeg_buffer, jpeg_buffer, nbytes); cinfo->src->next_input_byte = jpeg_buffer; cinfo->src->bytes_in_buffer = nbytes; return TRUE; }
Safe
[ "CWE-129" ]
LibRaw
89d065424f09b788f443734d44857289489ca9e2
1.971374925501996e+38
11
fixed two more problems found by fuzzer
0
static void __reg_bound_offset32(struct bpf_reg_state *reg) { u64 mask = 0xffffFFFF; struct tnum range = tnum_range(reg->umin_value & mask, reg->umax_value & mask); struct tnum lo32 = tnum_cast(reg->var_off, 4); struct tnum hi32 = tnum_lshift(tnum_rshift(reg->var_off, 32), 32); reg->var_off = tnum_or(hi32, tnum_intersect(lo32, range)); }
Safe
[]
linux
294f2fc6da27620a506e6c050241655459ccd6bd
1.6883229874087093e+38
10
bpf: Verifer, adjust_scalar_min_max_vals to always call update_reg_bounds() Currently, for all op verification we call __red_deduce_bounds() and __red_bound_offset() but we only call __update_reg_bounds() in bitwise ops. However, we could benefit from calling __update_reg_bounds() in BPF_ADD, BPF_SUB, and BPF_MUL cases as well. For example, a register with state 'R1_w=invP0' when we subtract from it, w1 -= 2 Before coerce we will now have an smin_value=S64_MIN, smax_value=U64_MAX and unsigned bounds umin_value=0, umax_value=U64_MAX. These will then be clamped to S32_MIN, U32_MAX values by coerce in the case of alu32 op as done in above example. However tnum will be a constant because the ALU op is done on a constant. Without update_reg_bounds() we have a scenario where tnum is a const but our unsigned bounds do not reflect this. By calling update_reg_bounds after coerce to 32bit we further refine the umin_value to U64_MAX in the alu64 case or U32_MAX in the alu32 case above. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/158507151689.15666.566796274289413203.stgit@john-Precision-5820-Tower
0
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { FILE *yyo = yyoutput; YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); }
Vulnerable
[ "CWE-19" ]
ntp
fe46889f7baa75fc8e6c0fcde87706d396ce1461
2.6028958385733727e+38
12
[Sec 2942]: Off-path DoS attack on auth broadcast mode. HStenn.
1
rpa_read_buffer(pool_t pool, const unsigned char **data, const unsigned char *end, unsigned char **buffer) { const unsigned char *p = *data; unsigned int len; if (p > end) return 0; len = *p++; if (p + len > end) return 0; *buffer = p_malloc(pool, len); memcpy(*buffer, p, len); *data += 1 + len; return len; }
Vulnerable
[ "CWE-125" ]
core
69ad3c902ea4bbf9f21ab1857d8923f975dc6145
1.1372862516199172e+38
20
auth: mech-rpa - Fail on zero len buffer
1
unsigned long long sendSync(int fd) { /* To start we need to send the SYNC command and return the payload. * The hiredis client lib does not understand this part of the protocol * and we don't want to mess with its buffers, so everything is performed * using direct low-level I/O. */ char buf[4096], *p; ssize_t nread; /* Send the SYNC command. */ if (write(fd,"SYNC\r\n",6) != 6) { fprintf(stderr,"Error writing to master\n"); exit(1); } /* Read $<payload>\r\n, making sure to read just up to "\n" */ p = buf; while(1) { nread = read(fd,p,1); if (nread <= 0) { fprintf(stderr,"Error reading bulk length while SYNCing\n"); exit(1); } if (*p == '\n' && p != buf) break; if (*p != '\n') p++; } *p = '\0'; if (buf[0] == '-') { printf("SYNC with master failed: %s\n", buf); exit(1); } return strtoull(buf+1,NULL,10); }
Safe
[ "CWE-119", "CWE-787" ]
redis
9fdcc15962f9ff4baebe6fdd947816f43f730d50
2.8940885958520404e+38
32
Security: fix redis-cli buffer overflow. Thanks to Fakhri Zulkifli for reporting it. The fix switched to dynamic allocation, copying the final prompt in the static buffer only at the end.
0
rb_str_intern(s) VALUE s; { volatile VALUE str = s; ID id; if (!RSTRING(str)->ptr || RSTRING(str)->len == 0) { rb_raise(rb_eArgError, "interning empty string"); } if (strlen(RSTRING(str)->ptr) != RSTRING(str)->len) rb_raise(rb_eArgError, "symbol string may not contain `\\0'"); if (OBJ_TAINTED(str) && rb_safe_level() >= 1 && !rb_sym_interned_p(str)) { rb_raise(rb_eSecurityError, "Insecure: can't intern tainted string"); } id = rb_intern(RSTRING(str)->ptr); return ID2SYM(id); }
Safe
[ "CWE-20" ]
ruby
e926ef5233cc9f1035d3d51068abe9df8b5429da
2.9251376315297123e+38
17
* random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export. * string.c (rb_str_tmp_new), intern.h: New function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
0
TiledInputFile::frameBuffer () const { Lock lock (*_data->_streamData); return _data->frameBuffer; }
Safe
[ "CWE-125" ]
openexr
e79d2296496a50826a15c667bf92bdc5a05518b4
1.6561409999624367e+38
5
fix memory leaks and invalid memory accesses Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
0
static CURLcode hsts_create(struct hsts *h, const char *hostname, bool subdomains, curl_off_t expires) { struct stsentry *sts = hsts_entry(); if(!sts) return CURLE_OUT_OF_MEMORY; sts->expires = expires; sts->includeSubDomains = subdomains; sts->host = strdup(hostname); if(!sts->host) { free(sts); return CURLE_OUT_OF_MEMORY; } Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node); return CURLE_OK; }
Vulnerable
[]
curl
fae6fea209a2d4db1582f608bd8cc8000721733a
1.4405620945451048e+38
19
hsts: ignore trailing dots when comparing hosts names CVE-2022-30115 Reported-by: Axel Chong Bug: https://curl.se/docs/CVE-2022-30115.html Closes #8821
1
static int racls_add_cb(const mbentry_t *mbentry, void *rock) { struct txn **txn = (struct txn **)rock; return mboxlist_update_racl(mbentry->name, NULL, mbentry, txn); }
Safe
[ "CWE-20" ]
cyrus-imapd
6bd33275368edfa71ae117de895488584678ac79
1.2071438852071734e+38
5
mboxlist: fix uninitialised memory use where pattern is "Other Users"
0
PHP_FUNCTION(locale_get_display_script) { get_icu_disp_value_src_php( LOC_SCRIPT_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU ); }
Vulnerable
[ "CWE-125" ]
php-src
97eff7eb57fc2320c267a949cffd622c38712484
2.6942642133860103e+38
4
Fix bug #72241: get_icu_value_internal out-of-bounds read
1
int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc, gpa_t gpa) { struct kvm_memslots *slots = kvm_memslots(kvm); int offset = offset_in_page(gpa); gfn_t gfn = gpa >> PAGE_SHIFT; ghc->gpa = gpa; ghc->generation = slots->generation; ghc->memslot = __gfn_to_memslot(slots, gfn); ghc->hva = gfn_to_hva_many(ghc->memslot, gfn, NULL); if (!kvm_is_error_hva(ghc->hva)) ghc->hva += offset; else return -EFAULT; return 0; }
Safe
[ "CWE-20", "CWE-787" ]
linux
fa3d315a4ce2c0891cdde262562e710d95fba19e
2.713875028640449e+38
18
KVM: Validate userspace_addr of memslot when registered This way, we can avoid checking the user space address many times when we read the guest memory. Although we can do the same for write if we check which slots are writable, we do not care write now: reading the guest memory happens more often than writing. [avi: change VERIFY_READ to VERIFY_WRITE] Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
0
static int wsrep_after_row(THD *thd) { DBUG_ENTER("wsrep_after_row"); /* enforce wsrep_max_ws_rows */ thd->wsrep_affected_rows++; if (wsrep_max_ws_rows && wsrep_thd_is_local(thd) && thd->wsrep_affected_rows > wsrep_max_ws_rows) { trans_rollback_stmt(thd) || trans_rollback(thd); my_message(ER_ERROR_DURING_COMMIT, "wsrep_max_ws_rows exceeded", MYF(0)); DBUG_RETURN(ER_ERROR_DURING_COMMIT); } else if (wsrep_after_row_internal(thd)) { DBUG_RETURN(ER_LOCK_DEADLOCK); } DBUG_RETURN(0); }
Safe
[ "CWE-416" ]
server
af810407f78b7f792a9bb8c47c8c532eb3b3a758
2.0457796894437582e+38
19
MDEV-28098 incorrect key in "dup value" error after long unique reset errkey after using it, so that it wouldn't affect the next error message in the next statement
0
GF_Box *pasp_New() { ISOM_DECL_BOX_ALLOC(GF_PixelAspectRatioBox, GF_ISOM_BOX_TYPE_PASP); return (GF_Box *)tmp; }
Safe
[ "CWE-125" ]
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
8.026652548780425e+36
5
fixed 2 possible heap overflows (inc. #1088)
0
void user_disable_single_step(struct task_struct *task) { clear_tsk_thread_flag(task, TIF_BLOCK_STEP); clear_tsk_thread_flag(task, TIF_SINGLE_STEP); }
Safe
[ "CWE-264", "CWE-269" ]
linux
dab6cf55f81a6e16b8147aed9a843e1691dcd318
2.875926315108535e+38
5
s390/ptrace: fix PSW mask check The PSW mask check of the PTRACE_POKEUSR_AREA command is incorrect. The PSW_MASK_USER define contains the PSW_MASK_ASC bits, the ptrace interface accepts all combinations for the address-space-control bits. To protect the kernel space the PSW mask check in ptrace needs to reject the address-space-control bit combination for home space. Fixes CVE-2014-3534 Cc: stable@vger.kernel.org Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
0
static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { .nops = 3, }; int status; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); if(status) goto out; status = encode_setattr(&xdr, args, args->server); if(status) goto out; status = encode_getfattr(&xdr, args->bitmask); out: return status; }
Safe
[ "CWE-703" ]
linux
dc0b027dfadfcb8a5504f7d8052754bf8d501ab9
2.3729465307325106e+38
21
NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
0
file_truncate (struct rw *rw, int64_t size) { struct rw_file *rwf = (struct rw_file *) rw; /* If the destination is an ordinary file then the original file * size doesn't matter. Truncate it to the source size. But * truncate it to zero first so the file is completely empty and * sparse. */ if (rwf->is_block) return; if (ftruncate (rwf->fd, 0) == -1 || ftruncate (rwf->fd, size) == -1) { fprintf (stderr, "%s: truncate: %m\n", rw->name); exit (EXIT_FAILURE); } rwf->rw.size = size; /* We can assume the destination is zero. */ destination_is_zero = true; }
Safe
[ "CWE-252" ]
libnbd
8d444b41d09a700c7ee6f9182a649f3f2d325abb
1.2936580407967473e+38
22
copy: CVE-2022-0485: Fail nbdcopy if NBD read or write fails nbdcopy has a nasty bug when performing multi-threaded copies using asynchronous nbd calls - it was blindly treating the completion of an asynchronous command as successful, rather than checking the *error parameter. This can result in the silent creation of a corrupted image in two different ways: when a read fails, we blindly wrote garbage to the destination; when a write fails, we did not flag that the destination was not written. Since nbdcopy already calls exit() on a synchronous read or write failure to a file, doing the same for an asynchronous op to an NBD server is the simplest solution. A nicer solution, but more invasive to code and thus not done here, might be to allow up to N retries of the transaction (in case the read or write failure was transient), or even having a mode where as much data is copied as possible (portions of the copy that failed would be logged on stderr, and nbdcopy would still fail with a non-zero exit status, but this would copy more than just stopping at the first error, as can be done with rsync or ddrescue). Note that since we rely on auto-retiring and do NOT call nbd_aio_command_completed, our completion callbacks must always return 1 (if they do not exit() first), even when acting on *error, so as not leave the command allocated until nbd_close. As such, there is no sane way to return an error to a manual caller of the callback, and therefore we can drop dead code that calls perror() and exit() if the callback "failed". It is also worth documenting the contract on when we must manually call the callback during the asynch_zero callback, so that we do not leak or double-free the command; thankfully, all the existing code paths were correct. The added testsuite script demonstrates several scenarios, some of which fail without the rest of this patch in place, and others which showcase ways in which sparse images can bypass errors. Once backports are complete, a followup patch on the main branch will edit docs/libnbd-security.pod with the mailing list announcement of the stable branch commit ids and release versions that incorporate this fix. Reported-by: Nir Soffer <nsoffer@redhat.com> Fixes: bc896eec4d ("copy: Implement multi-conn, multiple threads, multiple requests in flight.", v1.5.6) Fixes: https://bugzilla.redhat.com/2046194 Message-Id: <20220203202558.203013-6-eblake@redhat.com> Acked-by: Richard W.M. Jones <rjones@redhat.com> Acked-by: Nir Soffer <nsoffer@redhat.com> [eblake: fix error message per Nir, tweak requires lines in unit test per Rich] Reviewed-by: Laszlo Ersek <lersek@redhat.com>
0
static av_cold void avcodec_init(void) { static int initialized = 0; if (initialized != 0) return; initialized = 1; if (CONFIG_ME_CMP) ff_me_cmp_init_static(); }
Safe
[ "CWE-787" ]
FFmpeg
2080bc33717955a0e4268e738acf8c1eeddbf8cb
4.769499089223268e+37
11
avcodec/utils: correct align value for interplay Fixes out of array access Fixes: 452/fuzz-1-ffmpeg_VIDEO_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
0
static bool tEXtToDataBuf(const byte* bytes, long length, DataBuf& result) { static const char* hexdigits = "0123456789ABCDEF"; static int value[256]; static bool bFirst = true; if (bFirst) { for (int i = 0; i < 256; i++) value[i] = 0; for (int i = 0; i < 16; i++) { value[tolower(hexdigits[i])] = i + 1; value[toupper(hexdigits[i])] = i + 1; } bFirst = false; } // calculate length and allocate result; // count: number of \n in the header long count = 0; // p points to the current position in the array bytes const byte* p = bytes; // header is '\nsomething\n number\n hex' // => increment p until it points to the byte after the last \n // p must stay within bounds of the bytes array! while ((count < 3) && (p - bytes < length)) { // length is later used for range checks of p => decrement it for each increment of p --length; if (*p++ == '\n') { count++; } } for (long i = 0; i < length; i++) if (value[p[i]]) ++count; result.alloc((count + 1) / 2); // hex to binary count = 0; byte* r = result.pData_; int n = 0; // nibble for (long i = 0; i < length; i++) { if (value[p[i]]) { int v = value[p[i]] - 1; if (++count % 2) n = v * 16; // leading digit else *r++ = n + v; // trailing } } return true; }
Safe
[ "CWE-190" ]
exiv2
491c3ebe3b3faa6d8f75fb28146186792c2439da
4.1152934123663564e+37
51
Avoid negative integer overflow when `iccOffset > chunkLength`. This fixes #790. (cherry picked from commit 6fa2e31206127bd8bcac0269311f3775a8d6ea21)
0
GF_Err dvvC_box_read(GF_Box *s, GF_BitStream *bs) { return dvcC_box_read(s, bs); }
Safe
[ "CWE-787" ]
gpac
77510778516803b7f7402d7423c6d6bef50254c3
4.791172644784532e+36
4
fixed #2255
0
dns_message_renderend(dns_message_t *msg) { isc_buffer_t tmpbuf; isc_region_t r; int result; unsigned int count; REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(msg->buffer != NULL); if ((msg->rcode & ~DNS_MESSAGE_RCODE_MASK) != 0 && msg->opt == NULL) { /* * We have an extended rcode but are not using EDNS. */ return (DNS_R_FORMERR); } /* * If we're adding a OPT, TSIG or SIG(0) to a truncated message, * clear all rdatasets from the message except for the question * before adding the OPT, TSIG or SIG(0). If the question doesn't * fit, don't include it. */ if ((msg->tsigkey != NULL || msg->sig0key != NULL || msg->opt) && (msg->flags & DNS_MESSAGEFLAG_TC) != 0) { isc_buffer_t *buf; msgresetnames(msg, DNS_SECTION_ANSWER); buf = msg->buffer; dns_message_renderreset(msg); msg->buffer = buf; isc_buffer_clear(msg->buffer); isc_buffer_add(msg->buffer, DNS_MESSAGE_HEADERLEN); dns_compress_rollback(msg->cctx, 0); result = dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0); if (result != ISC_R_SUCCESS && result != ISC_R_NOSPACE) return (result); } /* * If we've got an OPT record, render it. */ if (msg->opt != NULL) { dns_message_renderrelease(msg, msg->opt_reserved); msg->opt_reserved = 0; /* * Set the extended rcode. */ msg->opt->ttl &= ~DNS_MESSAGE_EDNSRCODE_MASK; msg->opt->ttl |= ((msg->rcode << 20) & DNS_MESSAGE_EDNSRCODE_MASK); /* * Render. */ count = 0; result = renderset(msg->opt, dns_rootname, msg->cctx, msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); } /* * If we're adding a TSIG record, generate and render it. */ if (msg->tsigkey != NULL) { dns_message_renderrelease(msg, msg->sig_reserved); msg->sig_reserved = 0; result = dns_tsig_sign(msg); if (result != ISC_R_SUCCESS) return (result); count = 0; result = renderset(msg->tsig, msg->tsigname, msg->cctx, msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); } /* * If we're adding a SIG(0) record, generate and render it. */ if (msg->sig0key != NULL) { dns_message_renderrelease(msg, msg->sig_reserved); msg->sig_reserved = 0; result = dns_dnssec_signmessage(msg, msg->sig0key); if (result != ISC_R_SUCCESS) return (result); count = 0; /* * Note: dns_rootname is used here, not msg->sig0name, since * the owner name of a SIG(0) is irrelevant, and will not * be set in a message being rendered. */ result = renderset(msg->sig0, dns_rootname, msg->cctx, msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); } isc_buffer_usedregion(msg->buffer, &r); isc_buffer_init(&tmpbuf, r.base, r.length); dns_message_renderheader(msg, &tmpbuf); msg->buffer = NULL; /* forget about this buffer only on success XXX */ return (ISC_R_SUCCESS); }
Safe
[ "CWE-617" ]
bind9
6ed167ad0a647dff20c8cb08c944a7967df2d415
3.00752068195625e+38
111
Always keep a copy of the message this allows it to be available even when dns_message_parse() returns a error.
0
static double screen_units(double d) { switch (screen.unit) { case GERBV_INS: return COORD2INS(d); break; case GERBV_MILS: return COORD2MILS(d); break; case GERBV_MMS: return COORD2MMS(d); break; } return d; }
Safe
[ "CWE-200" ]
gerbv
319a8af890e4d0a5c38e6d08f510da8eefc42537
2.0371265938899597e+38
16
Remove local alias to parameter array Normalizing access to `gerbv_simplified_amacro_t::parameter` as a step to fix CVE-2021-40402
0
static int direct_splice_actor(struct pipe_inode_info *pipe, struct splice_desc *sd) { struct file *file = sd->u.file; return do_splice_from(pipe, file, &sd->pos, sd->total_len, sd->flags); }
Safe
[ "CWE-94" ]
linux-2.6
8811930dc74a503415b35c4a79d14fb0b408a361
2.161313114329676e+38
7
splice: missing user pointer access verification vmsplice_to_user() must always check the user pointer and length with access_ok() before copying. Likewise, for the slow path of copy_from_user_mmap_sem() we need to check that we may read from the user region. Signed-off-by: Jens Axboe <jens.axboe@oracle.com> Cc: Wojciech Purczynski <cliph@research.coseinc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
0
Default_object_creation_ctx::Default_object_creation_ctx( CHARSET_INFO *client_cs, CHARSET_INFO *connection_cl) : m_client_cs(client_cs), m_connection_cl(connection_cl) { }
Safe
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
2.5849225447804217e+38
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.
0
DEFUN (no_auto_summary, no_auto_summary_cmd, "no auto-summary", NO_STR "Enable automatic network number summarization\n") { return CMD_SUCCESS; }
Safe
[ "CWE-125" ]
frr
6d58272b4cf96f0daa846210dd2104877900f921
1.2884523830233344e+37
8
[bgpd] cleanup, compact and consolidate capability parsing code 2007-07-26 Paul Jakma <paul.jakma@sun.com> * (general) Clean up and compact capability parsing slightly. Consolidate validation of length and logging of generic TLV, and memcpy of capability data, thus removing such from cap specifc code (not always present or correct). * bgp_open.h: Add structures for the generic capability TLV header and for the data formats of the various specific capabilities we support. Hence remove the badly named, or else misdefined, struct capability. * bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data. Do the length checks *before* memcpy()'ing based on that length (stored capability - should have been validated anyway on input, but..). (bgp_afi_safi_valid_indices) new function to validate (afi,safi) which is about to be used as index into arrays, consolidates several instances of same, at least one of which appeared to be incomplete.. (bgp_capability_mp) Much condensed. (bgp_capability_orf_entry) New, process one ORF entry (bgp_capability_orf) Condensed. Fixed to process all ORF entries. (bgp_capability_restart) Condensed, and fixed to use a cap-specific type, rather than abusing capability_mp. (struct message capcode_str) added to aid generic logging. (size_t cap_minsizes[]) added to aid generic validation of capability length field. (bgp_capability_parse) Generic logging and validation of TLV consolidated here. Code compacted as much as possible. * bgp_packet.c: (bgp_open_receive) Capability parsers now use streams, so no more need here to manually fudge the input stream getp. (bgp_capability_msg_parse) use struct capability_mp_data. Validate lengths /before/ memcpy. Use bgp_afi_safi_valid_indices. (bgp_capability_receive) Exported for use by test harness. * bgp_vty.c: (bgp_show_summary) fix conversion warning (bgp_show_peer) ditto * bgp_debug.h: Fix storage 'extern' after type 'const'. * lib/log.c: (mes_lookup) warning about code not being in same-number array slot should be debug, not warning. E.g. BGP has several discontigious number spaces, allocating from different parts of a space is not uncommon (e.g. IANA assigned versus vendor-assigned code points in some number space).
0
static CURLcode ossl_seed(struct Curl_easy *data) { /* we have the "SSL is seeded" boolean static to prevent multiple time-consuming seedings in vain */ static bool ssl_seeded = FALSE; char fname[256]; if(ssl_seeded) return CURLE_OK; if(rand_enough()) { /* OpenSSL 1.1.0+ will return here */ ssl_seeded = TRUE; return CURLE_OK; } #ifndef RANDOM_FILE /* if RANDOM_FILE isn't defined, we only perform this if an option tells us to! */ if(data->set.str[STRING_SSL_RANDOM_FILE]) #define RANDOM_FILE "" /* doesn't matter won't be used */ #endif { /* let the option override the define */ RAND_load_file((data->set.str[STRING_SSL_RANDOM_FILE]? data->set.str[STRING_SSL_RANDOM_FILE]: RANDOM_FILE), RAND_LOAD_LENGTH); if(rand_enough()) return CURLE_OK; } #if defined(HAVE_RAND_EGD) /* only available in OpenSSL 0.9.5 and later */ /* EGD_SOCKET is set at configure time or not at all */ #ifndef EGD_SOCKET /* If we don't have the define set, we only do this if the egd-option is set */ if(data->set.str[STRING_SSL_EGDSOCKET]) #define EGD_SOCKET "" /* doesn't matter won't be used */ #endif { /* If there's an option and a define, the option overrides the define */ int ret = RAND_egd(data->set.str[STRING_SSL_EGDSOCKET]? data->set.str[STRING_SSL_EGDSOCKET]:EGD_SOCKET); if(-1 != ret) { if(rand_enough()) return CURLE_OK; } } #endif /* fallback to a custom seeding of the PRNG using a hash based on a current time */ do { unsigned char randb[64]; size_t len = sizeof(randb); size_t i, i_max; for(i = 0, i_max = len / sizeof(struct curltime); i < i_max; ++i) { struct curltime tv = Curl_now(); Curl_wait_ms(1); tv.tv_sec *= i + 1; tv.tv_usec *= (unsigned int)i + 2; tv.tv_sec ^= ((Curl_now().tv_sec + Curl_now().tv_usec) * (i + 3)) << 8; tv.tv_usec ^= (unsigned int) ((Curl_now().tv_sec + Curl_now().tv_usec) * (i + 4)) << 16; memcpy(&randb[i * sizeof(struct curltime)], &tv, sizeof(struct curltime)); } RAND_add(randb, (int)len, (double)len/2); } while(!rand_enough()); /* generates a default path for the random seed file */ fname[0] = 0; /* blank it first */ RAND_file_name(fname, sizeof(fname)); if(fname[0]) { /* we got a file name to try */ RAND_load_file(fname, RAND_LOAD_LENGTH); if(rand_enough()) return CURLE_OK; } infof(data, "libcurl is now using a weak random seed!\n"); return (rand_enough() ? CURLE_OK : CURLE_SSL_CONNECT_ERROR /* confusing error code */); }
Safe
[ "CWE-290" ]
curl
b09c8ee15771c614c4bf3ddac893cdb12187c844
1.1979059030032457e+38
89
vtls: add 'isproxy' argument to Curl_ssl_get/addsessionid() To make sure we set and extract the correct session. Reported-by: Mingtao Yang Bug: https://curl.se/docs/CVE-2021-22890.html CVE-2021-22890
0
static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { HValue* index = array_operation->GetKey(); if (!index->representation().IsInteger32()) return; HConstant* constant; HValue* subexpression; int32_t sign; if (index->IsAdd()) { sign = 1; HAdd* add = HAdd::cast(index); if (add->left()->IsConstant()) { subexpression = add->right(); constant = HConstant::cast(add->left()); } else if (add->right()->IsConstant()) { subexpression = add->left(); constant = HConstant::cast(add->right()); } else { return; } } else if (index->IsSub()) { sign = -1; HSub* sub = HSub::cast(index); if (sub->left()->IsConstant()) { subexpression = sub->right(); constant = HConstant::cast(sub->left()); } else if (sub->right()->IsConstant()) { subexpression = sub->left(); constant = HConstant::cast(sub->right()); } return; } else { return; } if (!constant->HasInteger32Value()) return; int32_t value = constant->Integer32Value() * sign; // We limit offset values to 30 bits because we want to avoid the risk of // overflows when the offset is added to the object header size. if (value >= 1 << array_operation->MaxIndexOffsetBits() || value < 0) return; array_operation->SetKey(subexpression); if (index->HasNoUses()) { index->DeleteAndReplaceWith(NULL); } ASSERT(value >= 0); array_operation->SetIndexOffset(static_cast<uint32_t>(value)); array_operation->SetDehoisted(true); }
Safe
[]
node
fd80a31e0697d6317ce8c2d289575399f4e06d21
3.0915621494626156e+38
46
deps: backport 5f836c from v8 upstream Original commit message: Fix Hydrogen bounds check elimination When combining bounds checks, they must all be moved before the first load/store that they are guarding. BUG=chromium:344186 LOG=y R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/172093002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@19475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 fix #8070
0
static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) { char message[JMSG_LENGTH_MAX]; jmpbuf_wrapper *jmpbufw; int ignore_warning = 0; jmpbufw = (jmpbuf_wrapper *) jpeg_info->client_data; if (jmpbufw != 0) { ignore_warning = jmpbufw->ignore_warning; } (jpeg_info->err->format_message)(jpeg_info,message); /* It is a warning message */ if (level < 0) { /* display only the 1st warning, as would do a default libjpeg * unless strace_level >= 3 */ if ((jpeg_info->err->num_warnings == 0) || (jpeg_info->err->trace_level >= 3)) { if (!ignore_warning) { gd_error("gd-jpeg, libjpeg: recoverable error: %s\n", message); } } jpeg_info->err->num_warnings++; } else { /* strace msg, Show it if trace_level >= level. */ if (jpeg_info->err->trace_level >= level) { if (!ignore_warning) { gd_error("gd-jpeg, libjpeg: strace message: %s\n", message); } } } return 1; }
Safe
[ "CWE-415" ]
php-src
089f7c0bc28d399b0420aa6ef058e4c1c120b2ae
2.8570188326846638e+38
36
Sync with upstream Even though libgd/libgd#492 is not a relevant bug fix for PHP, since the binding doesn't use the `gdImage*Ptr()` functions at all, we're porting the fix to stay in sync here.
0
get_dn(gnutls_x509_crt_t cert, const char *whom, gnutls_x509_dn_t * dn) { *dn = asn1_find_node(cert->cert, whom); if (!*dn) return GNUTLS_E_ASN1_ELEMENT_NOT_FOUND; return 0; }
Safe
[ "CWE-295" ]
gnutls
6e76e9b9fa845b76b0b9a45f05f4b54a052578ff
3.923959901329559e+37
7
on certificate import check whether the two signature algorithms match
0
QPDF_Stream::isDataModified() const { return (! this->token_filters.empty()); }
Safe
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
3.168865696457423e+37
4
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.
0
regenerate_ld_cache (GPtrArray *base_argv_array, GArray *base_fd_array, GFile *app_id_dir, const char *checksum, GFile *runtime_files, gboolean generate_ld_so_conf, GCancellable *cancellable, GError **error) { g_autoptr(FlatpakBwrap) bwrap = NULL; g_autoptr(GArray) combined_fd_array = NULL; g_autoptr(GFile) ld_so_cache = NULL; g_autoptr(GFile) ld_so_cache_tmp = NULL; g_autofree char *sandbox_cache_path = NULL; g_autofree char *tmp_basename = NULL; g_auto(GStrv) minimal_envp = NULL; g_autofree char *commandline = NULL; int exit_status; glnx_autofd int ld_so_fd = -1; g_autoptr(GFile) ld_so_dir = NULL; if (app_id_dir) ld_so_dir = g_file_get_child (app_id_dir, ".ld.so"); else { g_autoptr(GFile) base_dir = g_file_new_for_path (g_get_user_cache_dir ()); ld_so_dir = g_file_resolve_relative_path (base_dir, "flatpak/ld.so"); } ld_so_cache = g_file_get_child (ld_so_dir, checksum); ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache), O_RDONLY); if (ld_so_fd >= 0) return glnx_steal_fd (&ld_so_fd); g_debug ("Regenerating ld.so.cache %s", flatpak_file_get_path_cached (ld_so_cache)); if (!flatpak_mkdir_p (ld_so_dir, cancellable, error)) return FALSE; minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE); bwrap = flatpak_bwrap_new (minimal_envp); flatpak_bwrap_append_args (bwrap, base_argv_array); flatpak_run_setup_usr_links (bwrap, runtime_files); if (generate_ld_so_conf) { if (!add_ld_so_conf (bwrap, error)) return -1; } else flatpak_bwrap_add_args (bwrap, "--symlink", "../usr/etc/ld.so.conf", "/etc/ld.so.conf", NULL); tmp_basename = g_strconcat (checksum, ".XXXXXX", NULL); glnx_gen_temp_name (tmp_basename); sandbox_cache_path = g_build_filename ("/run/ld-so-cache-dir", tmp_basename, NULL); ld_so_cache_tmp = g_file_get_child (ld_so_dir, tmp_basename); flatpak_bwrap_add_args (bwrap, "--unshare-pid", "--unshare-ipc", "--unshare-net", "--proc", "/proc", "--dev", "/dev", "--bind", flatpak_file_get_path_cached (ld_so_dir), "/run/ld-so-cache-dir", NULL); if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error)) return -1; flatpak_bwrap_add_args (bwrap, "ldconfig", "-X", "-C", sandbox_cache_path, NULL); flatpak_bwrap_finish (bwrap); commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); g_debug ("Running: '%s'", commandline); combined_fd_array = g_array_new (FALSE, TRUE, sizeof (int)); g_array_append_vals (combined_fd_array, base_fd_array->data, base_fd_array->len); g_array_append_vals (combined_fd_array, bwrap->fds->data, bwrap->fds->len); /* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround */ if (!g_spawn_sync (NULL, (char **) bwrap->argv->pdata, bwrap->envp, G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, flatpak_bwrap_child_setup_cb, combined_fd_array, NULL, NULL, &exit_status, error)) return -1; if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status) != 0) { flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("ldconfig failed, exit status %d"), exit_status); return -1; } ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache_tmp), O_RDONLY); if (ld_so_fd < 0) { flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Can't open generated ld.so.cache")); return -1; } if (app_id_dir == NULL) { /* For runs without an app id dir we always regenerate the ld.so.cache */ unlink (flatpak_file_get_path_cached (ld_so_cache_tmp)); } else { g_autoptr(GFile) active = g_file_get_child (ld_so_dir, "active"); /* For app-dirs we keep one checksum alive, by pointing the active symlink to it */ /* Rename to known name, possibly overwriting existing ref if race */ if (rename (flatpak_file_get_path_cached (ld_so_cache_tmp), flatpak_file_get_path_cached (ld_so_cache)) == -1) { glnx_set_error_from_errno (error); return -1; } if (!flatpak_switch_symlink_and_remove (flatpak_file_get_path_cached (active), checksum, error)) return -1; } return glnx_steal_fd (&ld_so_fd); }
Safe
[ "CWE-94", "CWE-74" ]
flatpak
6d1773d2a54dde9b099043f07a2094a4f1c2f486
1.1013706760402452e+38
136
run: Convert all environment variables into bwrap arguments This avoids some of them being filtered out by a setuid bwrap. It also means that if they came from an untrusted source, they cannot be used to inject arbitrary code into a non-setuid bwrap via mechanisms like LD_PRELOAD. Because they get bundled into a memfd or temporary file, they do not actually appear in argv, ensuring that they remain inaccessible to processes running under a different uid (which is important if their values are tokens or other secrets). Signed-off-by: Simon McVittie <smcv@collabora.com> Part-of: https://github.com/flatpak/flatpak/security/advisories/GHSA-4ppf-fxf6-vxg2
0
void MainWindow::on_actionExportFrame_triggered() { if (Settings.playerGPU() || Settings.playerPreviewScale()) { Mlt::GLWidget* glw = qobject_cast<Mlt::GLWidget*>(MLT.videoWidget()); connect(glw, SIGNAL(imageReady()), SLOT(onGLWidgetImageReady())); MLT.setPreviewScale(0); glw->requestImage(); MLT.refreshConsumer(); } else { onGLWidgetImageReady(); } }
Safe
[ "CWE-89", "CWE-327", "CWE-295" ]
shotcut
f008adc039642307f6ee3378d378cdb842e52c1d
1.7689569058622197e+38
12
fix upgrade check is not using TLS correctly
0
static void ohci_wakeup(USBPort *port1) { OHCIState *s = port1->opaque; OHCIPort *port = &s->rhport[port1->index]; uint32_t intr = 0; if (port->ctrl & OHCI_PORT_PSS) { trace_usb_ohci_port_wakeup(port1->index); port->ctrl |= OHCI_PORT_PSSC; port->ctrl &= ~OHCI_PORT_PSS; intr = OHCI_INTR_RHSC; } /* Note that the controller can be suspended even if this port is not */ if ((s->ctl & OHCI_CTL_HCFS) == OHCI_USB_SUSPEND) { trace_usb_ohci_remote_wakeup(s->name); /* This is the one state transition the controller can do by itself */ s->ctl &= ~OHCI_CTL_HCFS; s->ctl |= OHCI_USB_RESUME; /* In suspend mode only ResumeDetected is possible, not RHSC: * see the OHCI spec 5.1.2.3. */ intr = OHCI_INTR_RD; } ohci_set_interrupt(s, intr); }
Safe
[ "CWE-835" ]
qemu
95ed56939eb2eaa4e2f349fe6dcd13ca4edfd8fb
1.3655794049642555e+38
24
usb: ohci: limit the number of link eds The guest may builds an infinite loop with link eds. This patch limit the number of linked ed to avoid this. Signed-off-by: Li Qiang <liqiang6-s@360.cn> Message-id: 5899a02e.45ca240a.6c373.93c1@mx.google.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
0
static void usbhid_disconnect(struct usb_interface *intf) { struct hid_device *hid = usb_get_intfdata(intf); struct usbhid_device *usbhid; if (WARN_ON(!hid)) return; usbhid = hid->driver_data; spin_lock_irq(&usbhid->lock); /* Sync with error and led handlers */ set_bit(HID_DISCONNECTED, &usbhid->iofl); spin_unlock_irq(&usbhid->lock); hid_destroy_device(hid); kfree(usbhid); }
Safe
[ "CWE-125", "CWE-787" ]
linux
f043bfc98c193c284e2cd768fefabe18ac2fed9b
1.285098088664238e+38
15
HID: usbhid: fix out-of-bounds bug The hid descriptor identifies the length and type of subordinate descriptors for a device. If the received hid descriptor is smaller than the size of the struct hid_descriptor, it is possible to cause out-of-bounds. In addition, if bNumDescriptors of the hid descriptor have an incorrect value, this can also cause out-of-bounds while approaching hdesc->desc[n]. So check the size of hid descriptor and bNumDescriptors. BUG: KASAN: slab-out-of-bounds in usbhid_parse+0x9b1/0xa20 Read of size 1 at addr ffff88006c5f8edf by task kworker/1:2/1261 CPU: 1 PID: 1261 Comm: kworker/1:2 Not tainted 4.14.0-rc1-42251-gebb2c2437d80 #169 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:16 dump_stack+0x292/0x395 lib/dump_stack.c:52 print_address_description+0x78/0x280 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 kasan_report+0x22f/0x340 mm/kasan/report.c:409 __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427 usbhid_parse+0x9b1/0xa20 drivers/hid/usbhid/hid-core.c:1004 hid_add_device+0x16b/0xb30 drivers/hid/hid-core.c:2944 usbhid_probe+0xc28/0x1100 drivers/hid/usbhid/hid-core.c:1369 usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26e/0x3d0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932 generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174 usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266 really_probe drivers/base/dd.c:413 driver_probe_device+0x610/0xa00 drivers/base/dd.c:557 __device_attach_driver+0x230/0x290 drivers/base/dd.c:653 bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463 __device_attach+0x26e/0x3d0 drivers/base/dd.c:710 device_initial_probe+0x1f/0x30 drivers/base/dd.c:757 bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523 device_add+0xd0b/0x1660 drivers/base/core.c:1835 usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457 hub_port_connect drivers/usb/core/hub.c:4903 hub_port_connect_change drivers/usb/core/hub.c:5009 port_event drivers/usb/core/hub.c:5115 hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195 process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119 worker_thread+0x221/0x1850 kernel/workqueue.c:2253 kthread+0x3a1/0x470 kernel/kthread.c:231 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431 Cc: stable@vger.kernel.org Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com> Tested-by: Andrey Konovalov <andreyknvl@google.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
0
int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC); if (FAILURE == ret) { return FAILURE; } if (pphar) { *pphar = phar; } phar->is_data = is_data; if (phar->is_zip) { return ret; } if (phar->is_brandnew) { phar->internal_file_start = 0; phar->is_zip = 1; phar->is_tar = 0; return SUCCESS; } /* we've reached here - the phar exists and is a regular phar */ if (error) { spprintf(error, 4096, "phar zip error: phar \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar", fname); } return FAILURE; }
Safe
[ "CWE-119" ]
php-src
a6fdc5bb27b20d889de0cd29318b3968aabb57bd
4.741072197384651e+37
33
Fix bug #71498: Out-of-Bound Read in phar_parse_zipfile()
0
static void sntp_cb(struct mg_connection *c, int ev, void *evd, void *fnd) { if (ev == MG_EV_READ) { int64_t milliseconds = mg_sntp_parse(c->recv.buf, c->recv.len); if (milliseconds > 0) { mg_call(c, MG_EV_SNTP_TIME, &milliseconds); LOG(LL_DEBUG, ("%u.%u, next at %lu", (unsigned) (milliseconds / 1000), (unsigned) (milliseconds % 1000), s_sntmp_next)); } c->recv.len = 0; // Clear receive buffer } else if (ev == MG_EV_CONNECT) { mg_sntp_send(c, (unsigned long) time(NULL)); } else if (ev == MG_EV_CLOSE) { } (void) fnd; (void) evd; }
Safe
[ "CWE-552" ]
mongoose
c65c8fdaaa257e0487ab0aaae9e8f6b439335945
3.2438012538881204e+38
16
Protect against the directory traversal in mg_upload()
0
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void) { return(sizeof(struct ndpi_flow_struct)); }
Safe
[ "CWE-416", "CWE-787" ]
nDPI
6a9f5e4f7c3fd5ddab3e6727b071904d76773952
1.502340393516076e+38
3
Fixed use after free caused by dangling pointer * This fix also improved RCE Injection detection Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
0
QPDF::checkLinearizationInternal() { // All comments referring to the PDF spec refer to the spec for // version 1.4. std::list<std::string> errors; std::list<std::string> warnings; // Check all values in linearization parameter dictionary LinParameters& p = this->m->linp; // L: file size in bytes -- checked by isLinearized // O: object number of first page std::vector<QPDFObjectHandle> const& pages = getAllPages(); if (p.first_page_object != pages.at(0).getObjectID()) { QTC::TC("qpdf", "QPDF err /O mismatch"); errors.push_back("first page object (/O) mismatch"); } // N: number of pages int npages = toI(pages.size()); if (p.npages != npages) { // Not tested in the test suite errors.push_back("page count (/N) mismatch"); } for (size_t i = 0; i < toS(npages); ++i) { QPDFObjectHandle const& page = pages.at(i); QPDFObjGen og(page.getObjGen()); if (this->m->xref_table[og].getType() == 2) { errors.push_back("page dictionary for page " + QUtil::uint_to_string(i) + " is compressed"); } } // T: offset of whitespace character preceding xref entry for object 0 this->m->file->seek(p.xref_zero_offset, SEEK_SET); while (1) { char ch; this->m->file->read(&ch, 1); if (! ((ch == ' ') || (ch == '\r') || (ch == '\n'))) { this->m->file->seek(-1, SEEK_CUR); break; } } if (this->m->file->tell() != this->m->first_xref_item_offset) { QTC::TC("qpdf", "QPDF err /T mismatch"); errors.push_back("space before first xref item (/T) mismatch " "(computed = " + QUtil::int_to_string(this->m->first_xref_item_offset) + "; file = " + QUtil::int_to_string(this->m->file->tell())); } // P: first page number -- Implementation note 124 says Acrobat // ignores this value, so we will too. // Check numbering of compressed objects in each xref section. // For linearized files, all compressed objects are supposed to be // at the end of the containing xref section if any object streams // are in use. if (this->m->uncompressed_after_compressed) { errors.push_back("linearized file contains an uncompressed object" " after a compressed one in a cross-reference stream"); } // Further checking requires optimization and order calculation. // Don't allow optimization to make changes. If it has to, then // the file is not properly linearized. We use the xref table to // figure out which objects are compressed and which are // uncompressed. { // local scope std::map<int, int> object_stream_data; for (std::map<QPDFObjGen, QPDFXRefEntry>::const_iterator iter = this->m->xref_table.begin(); iter != this->m->xref_table.end(); ++iter) { QPDFObjGen const& og = (*iter).first; QPDFXRefEntry const& entry = (*iter).second; if (entry.getType() == 2) { object_stream_data[og.getObj()] = entry.getObjStreamNumber(); } } optimize(object_stream_data, false); calculateLinearizationData(object_stream_data); } // E: offset of end of first page -- Implementation note 123 says // Acrobat includes on extra object here by mistake. pdlin fails // to place thumbnail images in section 9, so when thumbnails are // present, it also gets the wrong value for /E. It also doesn't // count outlines here when it should even though it places them // in part 6. This code fails to put thread information // dictionaries in part 9, so it actually gets the wrong value for // E when threads are present. In that case, it would probably // agree with pdlin. As of this writing, the test suite doesn't // contain any files with threads. if (this->m->part6.empty()) { throw std::logic_error("linearization part 6 unexpectedly empty"); } qpdf_offset_t min_E = -1; qpdf_offset_t max_E = -1; for (std::vector<QPDFObjectHandle>::iterator iter = this->m->part6.begin(); iter != this->m->part6.end(); ++iter) { QPDFObjGen og((*iter).getObjGen()); if (this->m->obj_cache.count(og) == 0) { // All objects have to have been dereferenced to be classified. throw std::logic_error("linearization part6 object not in cache"); } ObjCache const& oc = this->m->obj_cache[og]; min_E = std::max(min_E, oc.end_before_space); max_E = std::max(max_E, oc.end_after_space); } if ((p.first_page_end < min_E) || (p.first_page_end > max_E)) { QTC::TC("qpdf", "QPDF warn /E mismatch"); warnings.push_back("end of first page section (/E) mismatch: /E = " + QUtil::int_to_string(p.first_page_end) + "; computed = " + QUtil::int_to_string(min_E) + ".." + QUtil::int_to_string(max_E)); } // Check hint tables std::map<int, int> shared_idx_to_obj; checkHSharedObject(errors, warnings, pages, shared_idx_to_obj); checkHPageOffset(errors, warnings, pages, shared_idx_to_obj); checkHOutlines(warnings); // Report errors bool result = true; if (! errors.empty()) { result = false; for (std::list<std::string>::iterator iter = errors.begin(); iter != errors.end(); ++iter) { *this->m->out_stream << "ERROR: " << (*iter) << std::endl; } } if (! warnings.empty()) { result = false; for (std::list<std::string>::iterator iter = warnings.begin(); iter != warnings.end(); ++iter) { *this->m->out_stream << "WARNING: " << (*iter) << std::endl; } } return result; }
Safe
[ "CWE-787" ]
qpdf
d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e
2.712631247921529e+38
172
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.
0
static BOOL rdp_read_desktop_composition_capability_set(wStream* s, UINT16 length, rdpSettings* settings) { if (length < 6) return FALSE; Stream_Seek_UINT16(s); /* compDeskSupportLevel (2 bytes) */ return TRUE; }
Safe
[ "CWE-119", "CWE-125" ]
FreeRDP
3627aaf7d289315b614a584afb388f04abfb5bbf
2.5789630515558397e+38
9
Fixed #6011: Bounds check in rdp_read_font_capability_set
0