func
stringlengths
0
484k
target
int64
0
1
cwe
sequencelengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
Status TrySimplify(NodeDef* node, string* simplified_node_name) override { // 1. Discard aggregate nodes with a single input and no control deps. if (node->input_size() == 1) { *simplified_node_name = node->input(0); return Status::OK(); } // 2. Rewrite aggregations of N >= 2 identical terms. // All non-control inputs must be identical. bool all_equal = true; int num_inputs = 1; for (int i = 1; i < node->input_size(); ++i) { if (IsControlInput(node->input(i))) break; ++num_inputs; if (node->input(i) != node->input(0)) { all_equal = false; break; } } if (!all_equal) return Status::OK(); // And node should not be optimized earlier. const NodeScopeAndName node_scope_and_name = ParseNodeScopeAndName(node->name()); const string optimized_const_name = OptimizedNodeName(node_scope_and_name, "Const"); const string optimized_mul_name = OptimizedNodeName(node_scope_and_name, "Mul"); bool is_already_optimized = ctx().node_map->NodeExists(optimized_const_name) || ctx().node_map->NodeExists(optimized_mul_name); if (is_already_optimized) return Status::OK(); // At this point all preconditions are met, and we safely do the rewrite. VLOG(3) << "Simplify aggregation with identical inputs: node=" << node->name() << " num_inputs=" << num_inputs; // 1. Create constant node with value N. const auto type = GetDataTypeFromAttr(*node, "T"); Tensor t(type, TensorShape({})); Status status = SetTensorValue(type, num_inputs, &t); if (!status.ok()) { return errors::Internal("Failed to create const node: ", status.error_message()); } TensorValue value(&t); NodeDef* new_const_node = AddEmptyNode(optimized_const_name); status = ConstantFolding::CreateNodeDef(new_const_node->name(), value, new_const_node); if (!status.ok()) { return errors::Internal("Failed to create const node: ", status.error_message()); } new_const_node->set_device(node->device()); MaybeAddControlInput(NodeName(node->input(0)), new_const_node, ctx().optimized_graph, ctx().node_map); AddToOptimizationQueue(new_const_node); // 2. Replace the aggregate node with Mul(Const(N), x). NodeDef* new_mul_node = AddEmptyNode(optimized_mul_name); new_mul_node->set_op("Mul"); new_mul_node->set_device(node->device()); SetDataTypeToAttr(type, "T", new_mul_node); new_mul_node->add_input(new_const_node->name()); ctx().node_map->AddOutput(new_const_node->name(), new_mul_node->name()); new_mul_node->add_input(node->input(0)); ctx().node_map->AddOutput(node->input(0), new_mul_node->name()); ForwardControlDependencies(new_mul_node, {node}); *simplified_node_name = new_mul_node->name(); return Status::OK(); }
0
[ "CWE-476" ]
tensorflow
e6340f0665d53716ef3197ada88936c2a5f7a2d3
105,918,943,128,375,400,000,000,000,000,000,000,000
77
Handle a special grappler case resulting in crash. It might happen that a malformed input could be used to trick Grappler into trying to optimize a node with no inputs. This, in turn, would produce a null pointer dereference and a segfault. PiperOrigin-RevId: 369242852 Change-Id: I2e5cbe7aec243d34a6d60220ac8ac9b16f136f6b
*/ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb) { #define C(x) n->x = skb->x n->next = n->prev = NULL; n->sk = NULL; __copy_skb_header(n, skb); C(len); C(data_len); C(mac_len); n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len; n->cloned = 1; n->nohdr = 0; n->destructor = NULL; C(tail); C(end); C(head); C(head_frag); C(data); C(truesize); refcount_set(&n->users, 1); atomic_inc(&(skb_shinfo(skb)->dataref)); skb->cloned = 1; return n; #undef C
0
[ "CWE-20" ]
linux
2b16f048729bf35e6c28a40cbfad07239f9dcd90
78,432,198,574,162,660,000,000,000,000,000,000,000
29
net: create skb_gso_validate_mac_len() If you take a GSO skb, and split it into packets, will the MAC length (L2 + L3 + L4 headers + payload) of those packets be small enough to fit within a given length? Move skb_gso_mac_seglen() to skbuff.h with other related functions like skb_gso_network_seglen() so we can use it, and then create skb_gso_validate_mac_len to do the full calculation. Signed-off-by: Daniel Axtens <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void reds_remove_char_device(RedsState *reds, RedCharDevice *dev) { g_return_if_fail(reds != NULL); auto &devs(reds->char_devices); g_warn_if_fail(std::find(devs.begin(), devs.end(), red::shared_ptr<RedCharDevice>(dev)) != devs.end()); devs.remove(red::shared_ptr<RedCharDevice>(dev)); }
0
[]
spice
ca5bbc5692e052159bce1a75f55dc60b36078749
146,122,573,702,241,190,000,000,000,000,000,000,000
9
With OpenSSL 1.1: Disable client-initiated renegotiation. Fixes issue #49 Fixes BZ#1904459 Signed-off-by: Julien Ropé <[email protected]> Reported-by: BlackKD Acked-by: Frediano Ziglio <[email protected]>
PyObject* GetVariablesAsPyTuple() { return variable_watcher_.GetVariablesAsPyTuple(); }
0
[ "CWE-476", "CWE-908" ]
tensorflow
237822b59fc504dda2c564787f5d3ad9c4aa62d9
9,107,116,077,268,733,000,000,000,000,000,000,000
3
Fix tf.compat.v1.placeholder_with_default vulnerability with quantized types. When iterating through the tensor to extract shape values, an underlying missing kernel (`StridedSlice` for quantized types) causes an error, which then results in a `nullptr` being passed to `ParseDimensionValue()`, causing a segfault. The `nullptr` check allows the missing kernel error to propagate. Adding the missing kernel registrations allows the shape values to be extracted successfully. PiperOrigin-RevId: 445045957
check_for_opt_buffer_arg(typval_T *args, int idx) { return (args[idx].v_type == VAR_UNKNOWN || check_for_buffer_arg(args, idx)); }
0
[ "CWE-125", "CWE-122" ]
vim
1e56bda9048a9625bce6e660938c834c5c15b07d
108,690,907,360,912,950,000,000,000,000,000,000,000
5
patch 9.0.0104: going beyond allocated memory when evaluating string constant Problem: Going beyond allocated memory when evaluating string constant. Solution: Properly skip over <Key> form.
static int ff_layout_async_handle_error(struct rpc_task *task, struct nfs4_state *state, struct nfs_client *clp, struct pnfs_layout_segment *lseg, u32 idx) { int vers = clp->cl_nfs_mod->rpc_vers->number; if (task->tk_status >= 0) { ff_layout_mark_ds_reachable(lseg, idx); return 0; } /* Handle the case of an invalid layout segment */ if (!pnfs_is_valid_lseg(lseg)) return -NFS4ERR_RESET_TO_PNFS; switch (vers) { case 3: return ff_layout_async_handle_error_v3(task, lseg, idx); case 4: return ff_layout_async_handle_error_v4(task, state, clp, lseg, idx); default: /* should never happen */ WARN_ON_ONCE(1); return 0; } }
0
[ "CWE-787" ]
linux
ed34695e15aba74f45247f1ee2cf7e09d449f925
215,930,583,568,728,150,000,000,000,000,000,000,000
29
pNFS/flexfiles: fix incorrect size check in decode_nfs_fh() We (adam zabrocki, alexander matrosov, alexander tereshkin, maksym bazalii) observed the check: if (fh->size > sizeof(struct nfs_fh)) should not use the size of the nfs_fh struct which includes an extra two bytes from the size field. struct nfs_fh { unsigned short size; unsigned char data[NFS_MAXFHSIZE]; } but should determine the size from data[NFS_MAXFHSIZE] so the memcpy will not write 2 bytes beyond destination. The proposed fix is to compare against the NFS_MAXFHSIZE directly, as is done elsewhere in fs code base. Fixes: d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver") Signed-off-by: Nikola Livic <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
StrUtil_StrToUint(uint32 *out, // OUT const char *str) // IN : String to parse { char *ptr; unsigned long val; ASSERT(out); ASSERT(str); errno = 0; val = strtoul(str, &ptr, 0); *out = (uint32)val; /* * Input must be complete, no overflow, and value read must fit into 32 * bits - both signed and unsigned values are accepted. */ return *ptr == '\0' && errno != ERANGE && (val == (uint32)val || val == (int32)val); }
0
[ "CWE-362" ]
open-vm-tools
c1304ce8bfd9c0c33999e496bf7049d5c3d45821
298,021,417,427,034,500,000,000,000,000,000,000,000
22
randomly generate tmp directory name, and add StrUtil_ReplaceAll() function.
int RGWPutObj_ObjStore_S3::get_data(bufferlist& bl) { const int ret = RGWPutObj_ObjStore::get_data(bl); if (ret == 0) { const int ret_auth = do_aws4_auth_completion(); if (ret_auth < 0) { return ret_auth; } } return ret; }
0
[ "CWE-79" ]
ceph
8f90658c731499722d5f4393c8ad70b971d05f77
225,253,066,479,551,550,000,000,000,000,000,000,000
12
rgw: reject unauthenticated response-header actions Signed-off-by: Matt Benjamin <[email protected]> Reviewed-by: Casey Bodley <[email protected]> (cherry picked from commit d8dd5e513c0c62bbd7d3044d7e2eddcd897bd400)
static u64 vmci_transport_stream_rcvhiwat(struct vsock_sock *vsk) { return vmci_trans(vsk)->consume_size; }
0
[ "CWE-20", "CWE-269" ]
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
218,708,679,419,186,500,000,000,000,000,000,000,000
4
net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) { /* * Update run-time statistics of the 'current'. */ update_curr(cfs_rq); #ifdef CONFIG_SCHED_HRTICK /* * queued ticks are scheduled to match the slice, so don't bother * validating it and just reschedule. */ if (queued) return resched_task(rq_of(cfs_rq)->curr); /* * don't let the period tick interfere with the hrtick preemption */ if (!sched_feat(DOUBLE_TICK) && hrtimer_active(&rq_of(cfs_rq)->hrtick_timer)) return; #endif if (cfs_rq->nr_running > 1 || !sched_feat(WAKEUP_PREEMPT)) check_preempt_tick(cfs_rq, curr); }
0
[]
linux-2.6
6a6029b8cefe0ca7e82f27f3904dbedba3de4e06
176,718,966,539,035,640,000,000,000,000,000,000,000
25
sched: simplify sched_slice() Use the existing calc_delta_mine() calculation for sched_slice(). This saves a divide and simplifies the code because we share it with the other /cfs_rq->load users. It also improves code size: text data bss dec hex filename 42659 2740 144 45543 b1e7 sched.o.before 42093 2740 144 44977 afb1 sched.o.after Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]>
template<typename t> bool is_sameYZ(const CImg<t>& img) const { return is_sameYZ(img._height,img._depth);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
80,253,387,187,919,210,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
char* parseMap( char* ptr, FileNode& node ) { if (!ptr) CV_PARSE_ERROR_CPP("ptr is NULL"); if ( *ptr != '{' ) CV_PARSE_ERROR_CPP( "'{' - left-brace of map is missing" ); else ptr++; fs->convertToCollection(FileNode::MAP, node); for( ;; ) { ptr = skipSpaces( ptr ); if( !ptr || !*ptr ) break; if ( *ptr == '"' ) { FileNode child; ptr = parseKey( ptr, node, child ); if( !ptr || !*ptr ) break; ptr = skipSpaces( ptr ); if( !ptr || !*ptr ) break; if ( *ptr == '[' ) ptr = parseSeq( ptr, child ); else if ( *ptr == '{' ) ptr = parseMap( ptr, child ); else ptr = parseValue( ptr, child ); } ptr = skipSpaces( ptr ); if( !ptr || !*ptr ) break; if ( *ptr == ',' ) ptr++; else if ( *ptr == '}' ) break; else CV_PARSE_ERROR_CPP( "Unexpected character" ); } if (!ptr) CV_PARSE_ERROR_CPP("ptr is NULL"); if ( *ptr != '}' ) CV_PARSE_ERROR_CPP( "'}' - right-brace of map is missing" ); else ptr++; fs->finalizeCollection(node); return ptr; }
0
[ "CWE-787" ]
opencv
f42d5399aac80d371b17d689851406669c9b9111
87,027,736,227,714,410,000,000,000,000,000,000,000
59
core(persistence): add more checks for implementation limitations
void sdma_exit(struct hfi1_devdata *dd) { unsigned this_idx; struct sdma_engine *sde; for (this_idx = 0; dd->per_sdma && this_idx < dd->num_sdma; ++this_idx) { sde = &dd->per_sdma[this_idx]; if (!list_empty(&sde->dmawait)) dd_dev_err(dd, "sde %u: dmawait list not empty!\n", sde->this_idx); sdma_process_event(sde, sdma_event_e00_go_hw_down); del_timer_sync(&sde->err_progress_check_timer); /* * This waits for the state machine to exit so it is not * necessary to kill the sdma_sw_clean_up_task to make sure * it is not running. */ sdma_finalput(&sde->state); } }
0
[ "CWE-400", "CWE-401" ]
linux
34b3be18a04ecdc610aae4c48e5d1b799d8689f6
7,726,409,169,672,272,000,000,000,000,000,000,000
23
RDMA/hfi1: Prevent memory leak in sdma_init In sdma_init if rhashtable_init fails the allocated memory for tmp_sdma_rht should be released. Fixes: 5a52a7acf7e2 ("IB/hfi1: NULL pointer dereference when freeing rhashtable") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Navid Emamdoost <[email protected]> Acked-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow, NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) { void *func = NULL; u_int32_t a; u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx; int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId; NDPI_PROTOCOL_BITMASK detection_bitmask; NDPI_SAVE_AS_BITMASK(detection_bitmask, flow->packet.detected_protocol_stack[0]); if(flow->packet.payload_packet_len != 0) { if((proto_id != NDPI_PROTOCOL_UNKNOWN) && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask, ndpi_str->callback_buffer[proto_index].excluded_protocol_bitmask) == 0 && NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer[proto_index].detection_bitmask, detection_bitmask) != 0 && (ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask) { if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) && (ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL)) ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow), func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func; } if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { for (a = 0; a < ndpi_str->callback_buffer_size_tcp_payload; a++) { if((func != ndpi_str->callback_buffer_tcp_payload[a].func) && (ndpi_str->callback_buffer_tcp_payload[a].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_str->callback_buffer_tcp_payload[a].ndpi_selection_bitmask && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask, ndpi_str->callback_buffer_tcp_payload[a].excluded_protocol_bitmask) == 0 && NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_tcp_payload[a].detection_bitmask, detection_bitmask) != 0) { ndpi_str->callback_buffer_tcp_payload[a].func(ndpi_str, flow); if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) break; /* Stop after detecting the first protocol */ } } } } else { /* no payload */ if((proto_id != NDPI_PROTOCOL_UNKNOWN) && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask, ndpi_str->callback_buffer[proto_index].excluded_protocol_bitmask) == 0 && NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer[proto_index].detection_bitmask, detection_bitmask) != 0 && (ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_str->callback_buffer[proto_index].ndpi_selection_bitmask) { if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) && (ndpi_str->proto_defaults[flow->guessed_protocol_id].func != NULL) && ((ndpi_str->callback_buffer[flow->guessed_protocol_id].ndpi_selection_bitmask & NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD) == 0)) ndpi_str->proto_defaults[flow->guessed_protocol_id].func(ndpi_str, flow), func = ndpi_str->proto_defaults[flow->guessed_protocol_id].func; } for (a = 0; a < ndpi_str->callback_buffer_size_tcp_no_payload; a++) { if((func != ndpi_str->callback_buffer_tcp_payload[a].func) && (ndpi_str->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_str->callback_buffer_tcp_no_payload[a].ndpi_selection_bitmask && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask, ndpi_str->callback_buffer_tcp_no_payload[a].excluded_protocol_bitmask) == 0 && NDPI_BITMASK_COMPARE(ndpi_str->callback_buffer_tcp_no_payload[a].detection_bitmask, detection_bitmask) != 0) { ndpi_str->callback_buffer_tcp_no_payload[a].func(ndpi_str, flow); if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) break; /* Stop after detecting the first protocol */ } } } }
0
[ "CWE-416", "CWE-787" ]
nDPI
6a9f5e4f7c3fd5ddab3e6727b071904d76773952
291,663,434,794,527,100,000,000,000,000,000,000,000
72
Fixed use after free caused by dangling pointer * This fix also improved RCE Injection detection Signed-off-by: Toni Uhlig <[email protected]>
void transform_file_error(struct augeas *aug, const char *status, const char *filename, const char *format, ...) { char *ep = err_path(filename); struct tree *err; char *msg; va_list ap; int r; err = tree_fpath_cr(aug, ep); if (err == NULL) return; tree_unlink_children(aug, err); tree_set_value(err, status); err = tree_child_cr(err, s_message); if (err == NULL) return; va_start(ap, format); r = vasprintf(&msg, format, ap); va_end(ap); if (r < 0) return; tree_set_value(err, msg); free(msg); }
0
[]
augeas
f5b4fc0ceb0e5a2be5f3a19f63ad936897a3ac26
29,469,042,288,565,463,000,000,000,000,000,000,000
27
Fix umask handling when creating new files * src/transform.c (transform_save): faulty umask arithmetic would cause overly-open file modes when the umask contains "7", as the umask was incorrectly subtracted from the target file mode Fixes CVE-2013-6412, RHBZ#1034261
asmlinkage long sys_mknod(const char __user *filename, int mode, unsigned dev) { return sys_mknodat(AT_FDCWD, filename, mode, dev); }
0
[ "CWE-120" ]
linux-2.6
d70b67c8bc72ee23b55381bd6a884f4796692f77
92,630,951,168,071,620,000,000,000,000,000,000,000
4
[patch] vfs: fix lookup on deleted directory Lookup can install a child dentry for a deleted directory. This keeps the directory dentry alive, and the inode pinned in the cache and on disk, even after all external references have gone away. This isn't a big problem normally, since memory pressure or umount will clear out the directory dentry and its children, releasing the inode. But for UBIFS this causes problems because its orphan area can overflow. Fix this by returning ENOENT for all lookups on a S_DEAD directory before creating a child dentry. Thanks to Zoltan Sogor for noticing this while testing UBIFS, and Artem for the excellent analysis of the problem and testing. Reported-by: Artem Bityutskiy <[email protected]> Tested-by: Artem Bityutskiy <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Signed-off-by: Al Viro <[email protected]>
int sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len) { uint8_t ch = 0; const char* pstr = str; size_t length = 0; /* Fill data with parsed bytes */ while (sldns_parse_char(&ch, &pstr)) { if(*len < length+1) return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL; rd[length++] = ch; } if(!pstr) return LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE; *len = length; return LDNS_WIREPARSE_ERR_OK; }
0
[]
unbound
3f3cadd416d6efa92ff2d548ac090f42cd79fee9
287,740,809,289,865,480,000,000,000,000,000,000,000
17
- Fix Out of Bounds Write in sldns_str2wire_str_buf(), reported by X41 D-Sec.
static CURLUcode hostname_check(struct Curl_URL *u, char *hostname) { size_t len; size_t hlen = strlen(hostname); if(hostname[0] == '[') { const char *l = "0123456789abcdefABCDEF:."; if(hlen < 4) /* '[::]' is the shortest possible valid string */ return CURLUE_BAD_IPV6; hostname++; hlen -= 2; if(hostname[hlen] != ']') return CURLUE_BAD_IPV6; /* only valid letters are ok */ len = strspn(hostname, l); if(hlen != len) { hlen = len; if(hostname[len] == '%') { /* this could now be '%[zone id]' */ char zoneid[16]; int i = 0; char *h = &hostname[len + 1]; /* pass '25' if present and is a url encoded percent sign */ if(!strncmp(h, "25", 2) && h[2] && (h[2] != ']')) h += 2; while(*h && (*h != ']') && (i < 15)) zoneid[i++] = *h++; if(!i || (']' != *h)) /* impossible to reach? */ return CURLUE_MALFORMED_INPUT; zoneid[i] = 0; u->zoneid = strdup(zoneid); if(!u->zoneid) return CURLUE_OUT_OF_MEMORY; hostname[len] = ']'; /* insert end bracket */ hostname[len + 1] = 0; /* terminate the hostname */ } else return CURLUE_BAD_IPV6; /* hostname is fine */ } #ifdef ENABLE_IPV6 { char dest[16]; /* fits a binary IPv6 address */ char norm[MAX_IPADR_LEN]; hostname[hlen] = 0; /* end the address there */ if(1 != Curl_inet_pton(AF_INET6, hostname, dest)) return CURLUE_BAD_IPV6; /* check if it can be done shorter */ if(Curl_inet_ntop(AF_INET6, dest, norm, sizeof(norm)) && (strlen(norm) < hlen)) { strcpy(hostname, norm); hlen = strlen(norm); hostname[hlen + 1] = 0; } hostname[hlen] = ']'; /* restore ending bracket */ } #endif } else { /* letters from the second string are not ok */ len = strcspn(hostname, " \r\n\t/:#?!@"); if(hlen != len) /* hostname with bad content */ return CURLUE_BAD_HOSTNAME; } if(!hostname[0]) return CURLUE_NO_HOST; return CURLUE_OK; }
0
[]
curl
914aaab9153764ef8fa4178215b8ad89d3ac263a
163,590,049,580,864,550,000,000,000,000,000,000,000
73
urlapi: reject percent-decoding host name into separator bytes CVE-2022-27780 Reported-by: Axel Chong Bug: https://curl.se/docs/CVE-2022-27780.html Closes #8826
asmlinkage __visible void __sched schedule_user(void) { /* * If we come here after a random call to set_need_resched(), * or we have been woken up remotely but the IPI has not yet arrived, * we haven't yet exited the RCU idle mode. Do it here manually until * we find a better solution. * * NB: There are buggy callers of this function. Ideally we * should warn if prev_state != CONTEXT_USER, but that will trigger * too frequently to make sense yet. */ enum ctx_state prev_state = exception_enter(); schedule(); exception_exit(prev_state); }
0
[ "CWE-119" ]
linux
29d6455178a09e1dc340380c582b13356227e8df
97,660,652,498,854,940,000,000,000,000,000,000,000
16
sched: panic on corrupted stack end Until now, hitting this BUG_ON caused a recursive oops (because oops handling involves do_exit(), which calls into the scheduler, which in turn raises an oops), which caused stuff below the stack to be overwritten until a panic happened (e.g. via an oops in interrupt context, caused by the overwritten CPU index in the thread_info). Just panic directly. Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void *vnc_zlib_zalloc(void *x, unsigned items, unsigned size) { void *p; size *= items; size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1); p = g_malloc0(size); return (p); }
0
[ "CWE-401" ]
qemu
6bf21f3d83e95bcc4ba35a7a07cc6655e8b010b0
296,966,931,105,725,150,000,000,000,000,000,000,000
11
vnc: fix memory leak when vnc disconnect Currently when qemu receives a vnc connect, it creates a 'VncState' to represent this connection. In 'vnc_worker_thread_loop' it creates a local 'VncState'. The connection 'VcnState' and local 'VncState' exchange data in 'vnc_async_encoding_start' and 'vnc_async_encoding_end'. In 'zrle_compress_data' it calls 'deflateInit2' to allocate the libz library opaque data. The 'VncState' used in 'zrle_compress_data' is the local 'VncState'. In 'vnc_zrle_clear' it calls 'deflateEnd' to free the libz library opaque data. The 'VncState' used in 'vnc_zrle_clear' is the connection 'VncState'. In currently implementation there will be a memory leak when the vnc disconnect. Following is the asan output backtrack: Direct leak of 29760 byte(s) in 5 object(s) allocated from: 0 0xffffa67ef3c3 in __interceptor_calloc (/lib64/libasan.so.4+0xd33c3) 1 0xffffa65071cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb) 2 0xffffa5e968f7 in deflateInit2_ (/lib64/libz.so.1+0x78f7) 3 0xaaaacec58613 in zrle_compress_data ui/vnc-enc-zrle.c:87 4 0xaaaacec58613 in zrle_send_framebuffer_update ui/vnc-enc-zrle.c:344 5 0xaaaacec34e77 in vnc_send_framebuffer_update ui/vnc.c:919 6 0xaaaacec5e023 in vnc_worker_thread_loop ui/vnc-jobs.c:271 7 0xaaaacec5e5e7 in vnc_worker_thread ui/vnc-jobs.c:340 8 0xaaaacee4d3c3 in qemu_thread_start util/qemu-thread-posix.c:502 9 0xffffa544e8bb in start_thread (/lib64/libpthread.so.0+0x78bb) 10 0xffffa53965cb in thread_start (/lib64/libc.so.6+0xd55cb) This is because the opaque allocated in 'deflateInit2' is not freed in 'deflateEnd'. The reason is that the 'deflateEnd' calls 'deflateStateCheck' and in the latter will check whether 's->strm != strm'(libz's data structure). This check will be true so in 'deflateEnd' it just return 'Z_STREAM_ERROR' and not free the data allocated in 'deflateInit2'. The reason this happens is that the 'VncState' contains the whole 'VncZrle', so when calling 'deflateInit2', the 's->strm' will be the local address. So 's->strm != strm' will be true. To fix this issue, we need to make 'zrle' of 'VncState' to be a pointer. Then the connection 'VncState' and local 'VncState' exchange mechanism will work as expection. The 'tight' of 'VncState' has the same issue, let's also turn it to a pointer. Reported-by: Ying Fang <[email protected]> Signed-off-by: Li Qiang <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
TEST(RegexMatchExpression, MatchesElementExact) { BSONObj match = BSON("a" << "b"); BSONObj notMatch = BSON("a" << "c"); RegexMatchExpression regex; ASSERT(regex.init("", "b", "").isOK()); ASSERT(regex.matchesSingleElement(match.firstElement())); ASSERT(!regex.matchesSingleElement(notMatch.firstElement())); }
0
[]
mongo
b0ef26c639112b50648a02d969298650fbd402a4
295,420,873,710,924,350,000,000,000,000,000,000,000
10
SERVER-51083 Reject invalid UTF-8 from $regex match expressions
CURLcode Curl_add_timecondition(struct SessionHandle *data, Curl_send_buffer *req_buffer) { const struct tm *tm; char *buf = data->state.buffer; CURLcode result = CURLE_OK; struct tm keeptime; result = Curl_gmtime(data->set.timevalue, &keeptime); if(result) { failf(data, "Invalid TIMEVALUE"); return result; } tm = &keeptime; /* The If-Modified-Since header family should have their times set in * GMT as RFC2616 defines: "All HTTP date/time stamps MUST be * represented in Greenwich Mean Time (GMT), without exception. For the * purposes of HTTP, GMT is exactly equal to UTC (Coordinated Universal * Time)." (see page 20 of RFC2616). */ /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ snprintf(buf, BUFSIZE-1, "%s, %02d %s %4d %02d:%02d:%02d GMT", Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], tm->tm_mday, Curl_month[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec); switch(data->set.timecondition) { case CURL_TIMECOND_IFMODSINCE: default: result = Curl_add_bufferf(req_buffer, "If-Modified-Since: %s\r\n", buf); break; case CURL_TIMECOND_IFUNMODSINCE: result = Curl_add_bufferf(req_buffer, "If-Unmodified-Since: %s\r\n", buf); break; case CURL_TIMECOND_LASTMOD: result = Curl_add_bufferf(req_buffer, "Last-Modified: %s\r\n", buf); break; } return result; }
0
[ "CWE-284" ]
curl
f78ae415d24b9bd89d6c121c556e411fdb21c6aa
277,554,812,323,153,660,000,000,000,000,000,000,000
51
Don't clear GSSAPI state between each exchange in the negotiation GSSAPI doesn't work very well if we forget everything ever time. XX: Is Curl_http_done() the right place to do the final cleanup?
static boolean str_suffix(const char *begin_buf, const char *end_buf, const char *s) { const char *s1 = end_buf - 1, *s2 = strend(s) - 1; if (*s1 == 10) s1--; while (s1 >= begin_buf && s2 >= s) { if (*s1-- != *s2--) return false; } return s2 < s; }
0
[ "CWE-119" ]
texlive-source
6ed0077520e2b0da1fd060c7f88db7b2e6068e4c
290,989,681,877,933,700,000,000,000,000,000,000,000
11
writet1 protection against buffer overflow git-svn-id: svn://tug.org/texlive/trunk/Build/source@48697 c570f23f-e606-0410-a88d-b1316a301751
void add_pending_sha1(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags) { struct object *object = get_reference(revs, name, sha1, flags); add_pending_object(revs, object, name); }
0
[]
git
a937b37e766479c8e780b17cce9c4b252fd97e40
2,872,924,543,361,549,000,000,000,000,000,000,000
6
revision: quit pruning diff more quickly when possible When the revision traversal machinery is given a pathspec, we must compute the parent-diff for each commit to determine which ones are TREESAME. We set the QUICK diff flag to avoid looking at more entries than we need; we really just care whether there are any changes at all. But there is one case where we want to know a bit more: if --remove-empty is set, we care about finding cases where the change consists only of added entries (in which case we may prune the parent in try_to_simplify_commit()). To cover that case, our file_add_remove() callback does not quit the diff upon seeing an added entry; it keeps looking for other types of entries. But this means when --remove-empty is not set (and it is not by default), we compute more of the diff than is necessary. You can see this in a pathological case where a commit adds a very large number of entries, and we limit based on a broad pathspec. E.g.: perl -e ' chomp(my $blob = `git hash-object -w --stdin </dev/null`); for my $a (1..1000) { for my $b (1..1000) { print "100644 $blob\t$a/$b\n"; } } ' | git update-index --index-info git commit -qm add git rev-list HEAD -- . This case takes about 100ms now, but after this patch only needs 6ms. That's not a huge improvement, but it's easy to get and it protects us against even more pathological cases (e.g., going from 1 million to 10 million files would take ten times as long with the current code, but not increase at all after this patch). This is reported to minorly speed-up pathspec limiting in real world repositories (like the 100-million-file Windows repository), but probably won't make a noticeable difference outside of pathological setups. This patch actually covers the case without --remove-empty, and the case where we see only deletions. See the in-code comment for details. Note that we have to add a new member to the diff_options struct so that our callback can see the value of revs->remove_empty_trees. This callback parameter could be passed to the "add_remove" and "change" callbacks, but there's not much point. They already receive the diff_options struct, and doing it this way avoids having to update the function signature of the other callbacks (arguably the format_callback and output_prefix functions could benefit from the same simplification). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
static int _open_and_activate_luks2(struct crypt_device *cd, int keyslot, const char *name, const char *passphrase, size_t passphrase_size, uint32_t flags) { crypt_reencrypt_info ri; int r, rv; struct luks2_hdr *hdr = &cd->u.luks2.hdr; struct volume_key *vks = NULL; ri = LUKS2_reencrypt_status(hdr); if (ri == CRYPT_REENCRYPT_INVALID) return -EINVAL; if (ri > CRYPT_REENCRYPT_NONE) { if (name) r = _open_and_activate_reencrypt_device(cd, hdr, keyslot, name, passphrase, passphrase_size, flags); else { r = _open_all_keys(cd, hdr, keyslot, passphrase, passphrase_size, flags, &vks); if (r < 0) return r; rv = LUKS2_reencrypt_digest_verify(cd, hdr, vks); crypt_free_volume_key(vks); if (rv < 0) return rv; } } else r = _open_and_activate(cd, keyslot, name, passphrase, passphrase_size, flags); return r; }
0
[ "CWE-345" ]
cryptsetup
0113ac2d889c5322659ad0596d4cfc6da53e356c
332,712,131,356,400,250,000,000,000,000,000,000,000
37
Fix CVE-2021-4122 - LUKS2 reencryption crash recovery attack Fix possible attacks against data confidentiality through LUKS2 online reencryption extension crash recovery. An attacker can modify on-disk metadata to simulate decryption in progress with crashed (unfinished) reencryption step and persistently decrypt part of the LUKS device. This attack requires repeated physical access to the LUKS device but no knowledge of user passphrases. The decryption step is performed after a valid user activates the device with a correct passphrase and modified metadata. There are no visible warnings for the user that such recovery happened (except using the luksDump command). The attack can also be reversed afterward (simulating crashed encryption from a plaintext) with possible modification of revealed plaintext. The problem was caused by reusing a mechanism designed for actual reencryption operation without reassessing the security impact for new encryption and decryption operations. While the reencryption requires calculating and verifying both key digests, no digest was needed to initiate decryption recovery if the destination is plaintext (no encryption key). Also, some metadata (like encryption cipher) is not protected, and an attacker could change it. Note that LUKS2 protects visible metadata only when a random change occurs. It does not protect against intentional modification but such modification must not cause a violation of data confidentiality. The fix introduces additional digest protection of reencryption metadata. The digest is calculated from known keys and critical reencryption metadata. Now an attacker cannot create correct metadata digest without knowledge of a passphrase for used keyslots. For more details, see LUKS2 On-Disk Format Specification version 1.1.0.
const ContentEncoding::ContentEncryption* ContentEncoding::GetEncryptionByIndex( unsigned long idx) const { const ptrdiff_t count = encryption_entries_end_ - encryption_entries_; assert(count >= 0); if (idx >= static_cast<unsigned long>(count)) return NULL; return encryption_entries_[idx]; }
0
[ "CWE-20" ]
libvpx
34d54b04e98dd0bac32e9aab0fbda0bf501bc742
272,636,075,879,092,240,000,000,000,000,000,000,000
10
update libwebm to libwebm-1.0.0.27-358-gdbf1d10 changelog: https://chromium.googlesource.com/webm/libwebm/+log/libwebm-1.0.0.27-351-g9f23fbc..libwebm-1.0.0.27-358-gdbf1d10 Change-Id: I28a6b3ae02a53fb1f2029eee11e9449afb94c8e3
cmsBool WhitesAreEqual(int n, cmsUInt16Number White1[], cmsUInt16Number White2[] ) { int i; for (i=0; i < n; i++) { if (abs(White1[i] - White2[i]) > 0xf000) return TRUE; // Values are so extremely different that the fixup should be avoided if (White1[i] != White2[i]) return FALSE; } return TRUE; }
0
[ "CWE-125" ]
Little-CMS
d41071eb8cfea7aa10a9262c12bd95d5d9d81c8f
269,978,428,188,434,460,000,000,000,000,000,000,000
11
Contributed fixes from Oracle Two minor glitches
static ssize_t show_rxbuf(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%lu\n", NET_RX_RING_SIZE); }
0
[]
linux
f63c2c2032c2e3caad9add3b82cc6e91c376fd26
324,468,187,623,351,860,000,000,000,000,000,000,000
5
xen-netfront: restore __skb_queue_tail() positioning in xennet_get_responses() The commit referenced below moved the invocation past the "next" label, without any explanation. In fact this allows misbehaving backends undue control over the domain the frontend runs in, as earlier detected errors require the skb to not be freed (it may be retained for later processing via xennet_move_rx_slot(), or it may simply be unsafe to have it freed). This is CVE-2022-33743 / XSA-405. Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfront") Signed-off-by: Jan Beulich <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
rpc_release_client(struct rpc_clnt *clnt) { dprintk("RPC: rpc_release_client(%p)\n", clnt); if (list_empty(&clnt->cl_tasks)) wake_up(&destroy_wait); if (atomic_dec_and_test(&clnt->cl_count)) rpc_free_auth(clnt); }
0
[ "CWE-400", "CWE-399", "CWE-703" ]
linux
0b760113a3a155269a3fba93a409c640031dd68f
270,390,019,946,296,080,000,000,000,000,000,000,000
9
NLM: Don't hang forever on NLM unlock requests If the NLM daemon is killed on the NFS server, we can currently end up hanging forever on an 'unlock' request, instead of aborting. Basically, if the rpcbind request fails, or the server keeps returning garbage, we really want to quit instead of retrying. Tested-by: Vasily Averin <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Cc: [email protected]
int generic_file_mmap(struct file * file, struct vm_area_struct * vma) { struct address_space *mapping = file->f_mapping; if (!mapping->a_ops->readpage) return -ENOEXEC; file_accessed(file); vma->vm_ops = &generic_file_vm_ops; vma->vm_flags |= VM_CAN_NONLINEAR; return 0; }
0
[ "CWE-193" ]
linux-2.6
94ad374a0751f40d25e22e036c37f7263569d24c
159,130,227,368,222,010,000,000,000,000,000,000,000
11
Fix off-by-one error in iov_iter_advance() The iov_iter_advance() function would look at the iov->iov_len entry even though it might have iterated over the whole array, and iov was pointing past the end. This would cause DEBUG_PAGEALLOC to trigger a kernel page fault if the allocation was at the end of a page, and the next page was unallocated. The quick fix is to just change the order of the tests: check that there is any iovec data left before we check the iov entry itself. Thanks to Alexey Dobriyan for finding this case, and testing the fix. Reported-and-tested-by: Alexey Dobriyan <[email protected]> Cc: Nick Piggin <[email protected]> Cc: Andrew Morton <[email protected]> Cc: <[email protected]> [2.6.25.x, 2.6.26.x] Signed-off-by: Linus Torvalds <[email protected]>
static void brcmf_get_bwcap(struct brcmf_if *ifp, u32 bw_cap[]) { u32 band, mimo_bwcap; int err; band = WLC_BAND_2G; err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &band); if (!err) { bw_cap[NL80211_BAND_2GHZ] = band; band = WLC_BAND_5G; err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &band); if (!err) { bw_cap[NL80211_BAND_5GHZ] = band; return; } WARN_ON(1); return; } brcmf_dbg(INFO, "fallback to mimo_bw_cap info\n"); mimo_bwcap = 0; err = brcmf_fil_iovar_int_get(ifp, "mimo_bw_cap", &mimo_bwcap); if (err) /* assume 20MHz if firmware does not give a clue */ mimo_bwcap = WLC_N_BW_20ALL; switch (mimo_bwcap) { case WLC_N_BW_40ALL: bw_cap[NL80211_BAND_2GHZ] |= WLC_BW_40MHZ_BIT; /* fall-thru */ case WLC_N_BW_20IN2G_40IN5G: bw_cap[NL80211_BAND_5GHZ] |= WLC_BW_40MHZ_BIT; /* fall-thru */ case WLC_N_BW_20ALL: bw_cap[NL80211_BAND_2GHZ] |= WLC_BW_20MHZ_BIT; bw_cap[NL80211_BAND_5GHZ] |= WLC_BW_20MHZ_BIT; break; default: brcmf_err("invalid mimo_bw_cap value\n"); } }
0
[ "CWE-119", "CWE-703" ]
linux
ded89912156b1a47d940a0c954c43afbabd0c42c
127,848,347,751,940,760,000,000,000,000,000,000,000
40
brcmfmac: avoid potential stack overflow in brcmf_cfg80211_start_ap() User-space can choose to omit NL80211_ATTR_SSID and only provide raw IE TLV data. When doing so it can provide SSID IE with length exceeding the allowed size. The driver further processes this IE copying it into a local variable without checking the length. Hence stack can be corrupted and used as exploit. Cc: [email protected] # v4.7 Reported-by: Daxing Guo <[email protected]> Reviewed-by: Hante Meuleman <[email protected]> Reviewed-by: Pieter-Paul Giesberts <[email protected]> Reviewed-by: Franky Lin <[email protected]> Signed-off-by: Arend van Spriel <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
decompress(tvbuff_t *tvb, packet_info *pinfo, int offset, guint32 length, int codec, tvbuff_t **decompressed_tvb, int *decompressed_offset) { if (length > MAX_DECOMPRESSION_SIZE) { expert_add_info(pinfo, NULL, &ei_kafka_bad_decompression_length); return FALSE; } switch (codec) { case KAFKA_MESSAGE_CODEC_SNAPPY: return decompress_snappy(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); case KAFKA_MESSAGE_CODEC_LZ4: return decompress_lz4(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); case KAFKA_MESSAGE_CODEC_ZSTD: return decompress_zstd(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); case KAFKA_MESSAGE_CODEC_GZIP: return decompress_gzip(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); case KAFKA_MESSAGE_CODEC_NONE: return decompress_none(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); default: col_append_str(pinfo->cinfo, COL_INFO, " [unsupported compression type]"); return FALSE; } }
0
[ "CWE-401" ]
wireshark
f4374967bbf9c12746b8ec3cd54dddada9dd353e
131,163,132,085,109,450,000,000,000,000,000,000,000
22
Kafka: Limit our decompression size. Don't assume that the Internet has our best interests at heart when it gives us the size of our decompression buffer. Assign an arbitrary limit of 50 MB. This fixes #16739 in that it takes care of ** (process:17681): WARNING **: 20:03:07.440: Dissector bug, protocol Kafka, in packet 31: ../epan/proto.c:7043: failed assertion "end >= fi->start" which is different from the original error output. It looks like *that* might have taken care of in one of the other recent Kafka bug fixes. The decompression routines return a success or failure status. Use gbooleans instead of ints for that.
txSlot* fxNewArrayBufferInstance(txMachine* the) { txSlot* instance; txSlot* property; instance = fxNewObjectInstance(the); property = instance->next = fxNewSlot(the); property->flag = XS_INTERNAL_FLAG; property->kind = XS_ARRAY_BUFFER_KIND; property->value.arrayBuffer.address = C_NULL; property->value.arrayBuffer.detachKey = C_NULL; property = property->next = fxNewSlot(the); property->flag = XS_INTERNAL_FLAG; property->kind = XS_BUFFER_INFO_KIND; property->value.bufferInfo.length = 0; property->value.bufferInfo.maxLength = -1; return instance; }
0
[ "CWE-125" ]
moddable
135aa9a4a6a9b49b60aa730ebc3bcc6247d75c45
220,411,350,209,232,270,000,000,000,000,000,000,000
17
XS: #896
static void f_midi_read_data(struct usb_ep *ep, int cable, uint8_t *data, int length) { struct f_midi *midi = ep->driver_data; struct snd_rawmidi_substream *substream = midi->out_substream[cable]; if (!substream) /* Nobody is listening - throw it on the floor. */ return; if (!test_bit(cable, &midi->out_triggered)) return; snd_rawmidi_receive(substream, data, length); }
0
[ "CWE-415" ]
linux
7fafcfdf6377b18b2a726ea554d6e593ba44349f
181,168,576,315,894,850,000,000,000,000,000,000,000
15
USB: gadget: f_midi: fixing a possible double-free in f_midi It looks like there is a possibility of a double-free vulnerability on an error path of the f_midi_set_alt function in the f_midi driver. If the path is feasible then free_ep_req gets called twice: req->complete = f_midi_complete; err = usb_ep_queue(midi->out_ep, req, GFP_ATOMIC); => ... usb_gadget_giveback_request => f_midi_complete (CALLBACK) (inside f_midi_complete, for various cases of status) free_ep_req(ep, req); // first kfree if (err) { ERROR(midi, "%s: couldn't enqueue request: %d\n", midi->out_ep->name, err); free_ep_req(midi->out_ep, req); // second kfree return err; } The double-free possibility was introduced with commit ad0d1a058eac ("usb: gadget: f_midi: fix leak on failed to enqueue out requests"). Found by MOXCAFE tool. Signed-off-by: Tuba Yavuz <[email protected]> Fixes: ad0d1a058eac ("usb: gadget: f_midi: fix leak on failed to enqueue out requests") Acked-by: Felipe Balbi <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static int ZEND_FASTCALL ZEND_FETCH_R_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { return zend_fetch_var_address_helper_SPEC_VAR(BP_VAR_R, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); }
0
[]
php-src
ce96fd6b0761d98353761bf78d5bfb55291179fd
55,178,237,015,834,535,000,000,000,000,000,000,000
4
- fix #39863, do not accept paths with NULL in them. See http://news.php.net/php.internals/50191, trunk will have the patch later (adding a macro and/or changing (some) APIs. Patch by Rasmus
static void fastrpc_dma_buf_detatch(struct dma_buf *dmabuf, struct dma_buf_attachment *attachment) { struct fastrpc_dma_buf_attachment *a = attachment->priv; struct fastrpc_buf *buffer = dmabuf->priv; mutex_lock(&buffer->lock); list_del(&a->node); mutex_unlock(&buffer->lock); sg_free_table(&a->sgt); kfree(a); }
0
[ "CWE-400", "CWE-401" ]
linux
fc739a058d99c9297ef6bfd923b809d85855b9a9
106,514,757,560,599,550,000,000,000,000,000,000,000
12
misc: fastrpc: prevent memory leak in fastrpc_dma_buf_attach In fastrpc_dma_buf_attach if dma_get_sgtable fails the allocated memory for a should be released. Signed-off-by: Navid Emamdoost <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
static Image *ReadMETAImage(const ImageInfo *image_info, ExceptionInfo *exception) { Image *buff, *image; MagickBooleanType status; StringInfo *profile; size_t length; void *blob; /* Open file containing binary metadata */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); image=AcquireImage(image_info,exception); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } image->columns=1; image->rows=1; if (SetImageBackgroundColor(image,exception) == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } length=1; if (LocaleNCompare(image_info->magick,"8BIM",4) == 0) { /* Read 8BIM binary metadata. */ buff=AcquireImage((ImageInfo *) NULL,exception); if (buff == (Image *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char)); if (blob == (unsigned char *) NULL) { buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(buff->blob,blob,length); if (LocaleCompare(image_info->magick,"8BIMTEXT") == 0) { length=(size_t) parse8BIM(image, buff); if (length & 1) (void) WriteBlobByte(buff,0x0); } else if (LocaleCompare(image_info->magick,"8BIMWTEXT") == 0) { length=(size_t) parse8BIMW(image, buff); if (length & 1) (void) WriteBlobByte(buff,0x0); } else CopyBlob(image,buff); profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t) GetBlobSize(buff)); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); status=SetImageProfile(image,"8bim",profile,exception); profile=DestroyStringInfo(profile); if (status == MagickFalse) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=DetachBlob(buff->blob); blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); } if (LocaleNCompare(image_info->magick,"APP1",4) == 0) { char name[MagickPathExtent]; (void) FormatLocaleString(name,MagickPathExtent,"APP%d",1); buff=AcquireImage((ImageInfo *) NULL,exception); if (buff == (Image *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char)); if (blob == (unsigned char *) NULL) { buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(buff->blob,blob,length); if (LocaleCompare(image_info->magick,"APP1JPEG") == 0) { Image *iptc; int result; if (image_info->profile == (void *) NULL) { blob=DetachBlob(buff->blob); blob=RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(CoderError,"NoIPTCProfileAvailable"); } profile=CloneStringInfo((StringInfo *) image_info->profile); iptc=AcquireImage((ImageInfo *) NULL,exception); if (iptc == (Image *) NULL) { blob=DetachBlob(buff->blob); blob=RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(iptc->blob,GetStringInfoDatum(profile), GetStringInfoLength(profile)); result=jpeg_embed(image,buff,iptc); blob=DetachBlob(iptc->blob); blob=RelinquishMagickMemory(blob); iptc=DestroyImage(iptc); if (result == 0) { blob=DetachBlob(buff->blob); blob=RelinquishMagickMemory(blob); buff=DestroyImage(buff); ThrowReaderException(CoderError,"JPEGEmbeddingFailed"); } } else CopyBlob(image,buff); profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t) GetBlobSize(buff)); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); status=SetImageProfile(image,name,profile,exception); profile=DestroyStringInfo(profile); if (status == MagickFalse) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=DetachBlob(buff->blob); blob=RelinquishMagickMemory(blob); buff=DestroyImage(buff); } if ((LocaleCompare(image_info->magick,"ICC") == 0) || (LocaleCompare(image_info->magick,"ICM") == 0)) { buff=AcquireImage((ImageInfo *) NULL,exception); if (buff == (Image *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char)); if (blob == (unsigned char *) NULL) { buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(buff->blob,blob,length); CopyBlob(image,buff); profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t) GetBlobSize(buff)); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); (void) SetImageProfile(image,"icc",profile,exception); profile=DestroyStringInfo(profile); blob=DetachBlob(buff->blob); blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); } if (LocaleCompare(image_info->magick,"IPTC") == 0) { buff=AcquireImage((ImageInfo *) NULL,exception); if (buff == (Image *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char)); if (blob == (unsigned char *) NULL) { buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(buff->blob,blob,length); CopyBlob(image,buff); profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t) GetBlobSize(buff)); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); (void) SetImageProfile(image,"8bim",profile,exception); profile=DestroyStringInfo(profile); blob=DetachBlob(buff->blob); blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); } if (LocaleCompare(image_info->magick,"XMP") == 0) { buff=AcquireImage((ImageInfo *) NULL,exception); if (buff == (Image *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); blob=(unsigned char *) AcquireQuantumMemory(length,sizeof(unsigned char)); if (blob == (unsigned char *) NULL) { buff=DestroyImage(buff); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } AttachBlob(buff->blob,blob,length); CopyBlob(image,buff); profile=BlobToStringInfo(GetBlobStreamData(buff),(size_t) GetBlobSize(buff)); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); (void) SetImageProfile(image,"xmp",profile,exception); profile=DestroyStringInfo(profile); blob=DetachBlob(buff->blob); blob=(unsigned char *) RelinquishMagickMemory(blob); buff=DestroyImage(buff); } (void) CloseBlob(image); return(GetFirstImageInList(image)); }
0
[ "CWE-772" ]
ImageMagick
46382526a3f09cebf9f2af680fc55b2a668fcbef
104,328,434,513,824,350,000,000,000,000,000,000,000
226
https://github.com/ImageMagick/ImageMagick/issues/643
extended_color_content(int color, int *r, int *g, int *b) { return NCURSES_SP_NAME(extended_color_content) (CURRENT_SCREEN, color, r, g, b); }
0
[]
ncurses
790a85dbd4a81d5f5d8dd02a44d84f01512ef443
225,577,539,815,926,600,000,000,000,000,000,000,000
6
ncurses 6.2 - patch 20200531 + correct configure version-check/warnng for g++ to allow for 10.x + re-enable "bel" in konsole-base (report by Nia Huang) + add linux-s entry (patch by Alexandre Montaron). + drop long-obsolete convert_configure.pl + add test/test_parm.c, for checking tparm changes. + improve parameter-checking for tparm, adding function _nc_tiparm() to handle the most-used case, which accepts only numeric parameters (report/testcase by "puppet-meteor"). + use a more conservative estimate of the buffer-size in lib_tparm.c's save_text() and save_number(), in case the sprintf() function passes-through unexpected characters from a format specifier (report/testcase by "puppet-meteor"). + add a check for end-of-string in cvtchar to handle a malformed string in infotocap (report/testcase by "puppet-meteor").
static int find_dynamic_major(void) { int i; struct char_device_struct *cd; for (i = ARRAY_SIZE(chrdevs)-1; i >= CHRDEV_MAJOR_DYN_END; i--) { if (chrdevs[i] == NULL) return i; } for (i = CHRDEV_MAJOR_DYN_EXT_START; i >= CHRDEV_MAJOR_DYN_EXT_END; i--) { for (cd = chrdevs[major_to_index(i)]; cd; cd = cd->next) if (cd->major == i) break; if (cd == NULL) return i; } return -EBUSY; }
0
[ "CWE-362" ]
linux
68faa679b8be1a74e6663c21c3a9d25d32f1c079
180,418,310,694,718,540,000,000,000,000,000,000,000
22
chardev: Avoid potential use-after-free in 'chrdev_open()' 'chrdev_open()' calls 'cdev_get()' to obtain a reference to the 'struct cdev *' stashed in the 'i_cdev' field of the target inode structure. If the pointer is NULL, then it is initialised lazily by looking up the kobject in the 'cdev_map' and so the whole procedure is protected by the 'cdev_lock' spinlock to serialise initialisation of the shared pointer. Unfortunately, it is possible for the initialising thread to fail *after* installing the new pointer, for example if the subsequent '->open()' call on the file fails. In this case, 'cdev_put()' is called, the reference count on the kobject is dropped and, if nobody else has taken a reference, the release function is called which finally clears 'inode->i_cdev' from 'cdev_purge()' before potentially freeing the object. The problem here is that a racing thread can happily take the 'cdev_lock' and see the non-NULL pointer in the inode, which can result in a refcount increment from zero and a warning: | ------------[ cut here ]------------ | refcount_t: addition on 0; use-after-free. | WARNING: CPU: 2 PID: 6385 at lib/refcount.c:25 refcount_warn_saturate+0x6d/0xf0 | Modules linked in: | CPU: 2 PID: 6385 Comm: repro Not tainted 5.5.0-rc2+ #22 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 | RIP: 0010:refcount_warn_saturate+0x6d/0xf0 | Code: 05 55 9a 15 01 01 e8 9d aa c8 ff 0f 0b c3 80 3d 45 9a 15 01 00 75 ce 48 c7 c7 00 9c 62 b3 c6 08 | RSP: 0018:ffffb524c1b9bc70 EFLAGS: 00010282 | RAX: 0000000000000000 RBX: ffff9e9da1f71390 RCX: 0000000000000000 | RDX: ffff9e9dbbd27618 RSI: ffff9e9dbbd18798 RDI: ffff9e9dbbd18798 | RBP: 0000000000000000 R08: 000000000000095f R09: 0000000000000039 | R10: 0000000000000000 R11: ffffb524c1b9bb20 R12: ffff9e9da1e8c700 | R13: ffffffffb25ee8b0 R14: 0000000000000000 R15: ffff9e9da1e8c700 | FS: 00007f3b87d26700(0000) GS:ffff9e9dbbd00000(0000) knlGS:0000000000000000 | CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 | CR2: 00007fc16909c000 CR3: 000000012df9c000 CR4: 00000000000006e0 | DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 | DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 | Call Trace: | kobject_get+0x5c/0x60 | cdev_get+0x2b/0x60 | chrdev_open+0x55/0x220 | ? cdev_put.part.3+0x20/0x20 | do_dentry_open+0x13a/0x390 | path_openat+0x2c8/0x1470 | do_filp_open+0x93/0x100 | ? selinux_file_ioctl+0x17f/0x220 | do_sys_open+0x186/0x220 | do_syscall_64+0x48/0x150 | entry_SYSCALL_64_after_hwframe+0x44/0xa9 | RIP: 0033:0x7f3b87efcd0e | Code: 89 54 24 08 e8 a3 f4 ff ff 8b 74 24 0c 48 8b 3c 24 41 89 c0 44 8b 54 24 08 b8 01 01 00 00 89 f4 | RSP: 002b:00007f3b87d259f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000101 | RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3b87efcd0e | RDX: 0000000000000000 RSI: 00007f3b87d25a80 RDI: 00000000ffffff9c | RBP: 00007f3b87d25e90 R08: 0000000000000000 R09: 0000000000000000 | R10: 0000000000000000 R11: 0000000000000293 R12: 00007ffe188f504e | R13: 00007ffe188f504f R14: 00007f3b87d26700 R15: 0000000000000000 | ---[ end trace 24f53ca58db8180a ]--- Since 'cdev_get()' can already fail to obtain a reference, simply move it over to use 'kobject_get_unless_zero()' instead of 'kobject_get()', which will cause the racing thread to return -ENXIO if the initialising thread fails unexpectedly. Cc: Hillf Danton <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Al Viro <[email protected]> Reported-by: [email protected] Signed-off-by: Will Deacon <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_data) { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; if (psf_ftell (psf) == psf->filelength) return SF_TRUE ; return SF_FALSE ; } /* sf_flac_eof_callback */
0
[ "CWE-119", "CWE-369" ]
libsndfile
60b234301adf258786d8b90be5c1d437fc8799e0
114,600,267,245,302,960,000,000,000,000,000,000,000
8
src/flac.c: Improve error handling Especially when dealing with corrupt or malicious files.
void virDomainHostdevDefFree(virDomainHostdevDefPtr def) { if (!def) return; /* free all subordinate objects */ virDomainHostdevDefClear(def); /* If there is a parentnet device object, it will handle freeing * the memory. */ if (!def->parentnet) VIR_FREE(def); }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
205,048,079,600,559,230,000,000,000,000,000,000,000
14
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
static void bnx2x_get_cnic_mac_hwinfo(struct bnx2x *bp) { u32 val, val2; int func = BP_ABS_FUNC(bp); int port = BP_PORT(bp); u8 *iscsi_mac = bp->cnic_eth_dev.iscsi_mac; u8 *fip_mac = bp->fip_mac; if (IS_MF(bp)) { /* iSCSI and FCoE NPAR MACs: if there is no either iSCSI or * FCoE MAC then the appropriate feature should be disabled. * In non SD mode features configuration comes from struct * func_ext_config. */ if (!IS_MF_SD(bp)) { u32 cfg = MF_CFG_RD(bp, func_ext_config[func].func_cfg); if (cfg & MACP_FUNC_CFG_FLAGS_ISCSI_OFFLOAD) { val2 = MF_CFG_RD(bp, func_ext_config[func]. iscsi_mac_addr_upper); val = MF_CFG_RD(bp, func_ext_config[func]. iscsi_mac_addr_lower); bnx2x_set_mac_buf(iscsi_mac, val, val2); BNX2X_DEV_INFO ("Read iSCSI MAC: %pM\n", iscsi_mac); } else { bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; } if (cfg & MACP_FUNC_CFG_FLAGS_FCOE_OFFLOAD) { val2 = MF_CFG_RD(bp, func_ext_config[func]. fcoe_mac_addr_upper); val = MF_CFG_RD(bp, func_ext_config[func]. fcoe_mac_addr_lower); bnx2x_set_mac_buf(fip_mac, val, val2); BNX2X_DEV_INFO ("Read FCoE L2 MAC: %pM\n", fip_mac); } else { bp->flags |= NO_FCOE_FLAG; } bp->mf_ext_config = cfg; } else { /* SD MODE */ if (BNX2X_IS_MF_SD_PROTOCOL_ISCSI(bp)) { /* use primary mac as iscsi mac */ memcpy(iscsi_mac, bp->dev->dev_addr, ETH_ALEN); BNX2X_DEV_INFO("SD ISCSI MODE\n"); BNX2X_DEV_INFO ("Read iSCSI MAC: %pM\n", iscsi_mac); } else if (BNX2X_IS_MF_SD_PROTOCOL_FCOE(bp)) { /* use primary mac as fip mac */ memcpy(fip_mac, bp->dev->dev_addr, ETH_ALEN); BNX2X_DEV_INFO("SD FCoE MODE\n"); BNX2X_DEV_INFO ("Read FIP MAC: %pM\n", fip_mac); } } /* If this is a storage-only interface, use SAN mac as * primary MAC. Notice that for SD this is already the case, * as the SAN mac was copied from the primary MAC. */ if (IS_MF_FCOE_AFEX(bp)) memcpy(bp->dev->dev_addr, fip_mac, ETH_ALEN); } else { val2 = SHMEM_RD(bp, dev_info.port_hw_config[port]. iscsi_mac_upper); val = SHMEM_RD(bp, dev_info.port_hw_config[port]. iscsi_mac_lower); bnx2x_set_mac_buf(iscsi_mac, val, val2); val2 = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_fip_mac_upper); val = SHMEM_RD(bp, dev_info.port_hw_config[port]. fcoe_fip_mac_lower); bnx2x_set_mac_buf(fip_mac, val, val2); } /* Disable iSCSI OOO if MAC configuration is invalid. */ if (!is_valid_ether_addr(iscsi_mac)) { bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG; eth_zero_addr(iscsi_mac); } /* Disable FCoE if MAC configuration is invalid. */ if (!is_valid_ether_addr(fip_mac)) { bp->flags |= NO_FCOE_FLAG; eth_zero_addr(bp->fip_mac); } }
0
[ "CWE-20" ]
linux
8914a595110a6eca69a5e275b323f5d09e18f4f9
39,863,444,878,815,440,000,000,000,000,000,000,000
91
bnx2x: disable GSO where gso_size is too big for hardware If a bnx2x card is passed a GSO packet with a gso_size larger than ~9700 bytes, it will cause a firmware error that will bring the card down: bnx2x: [bnx2x_attn_int_deasserted3:4323(enP24p1s0f0)]MC assert! bnx2x: [bnx2x_mc_assert:720(enP24p1s0f0)]XSTORM_ASSERT_LIST_INDEX 0x2 bnx2x: [bnx2x_mc_assert:736(enP24p1s0f0)]XSTORM_ASSERT_INDEX 0x0 = 0x00000000 0x25e43e47 0x00463e01 0x00010052 bnx2x: [bnx2x_mc_assert:750(enP24p1s0f0)]Chip Revision: everest3, FW Version: 7_13_1 ... (dump of values continues) ... Detect when the mac length of a GSO packet is greater than the maximum packet size (9700 bytes) and disable GSO. Signed-off-by: Daniel Axtens <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void unix_dgram_peer_wake_disconnect(struct sock *sk, struct sock *other) { struct unix_sock *u, *u_other; u = unix_sk(sk); u_other = unix_sk(other); spin_lock(&u_other->peer_wait.lock); if (u->peer_wake.private == other) { __remove_wait_queue(&u_other->peer_wait, &u->peer_wake); u->peer_wake.private = NULL; } spin_unlock(&u_other->peer_wait.lock); }
0
[]
net
7d267278a9ece963d77eefec61630223fce08c6c
312,390,729,075,017,030,000,000,000,000,000,000,000
16
unix: avoid use-after-free in ep_remove_wait_queue Rainer Weikusat <[email protected]> writes: An AF_UNIX datagram socket being the client in an n:1 association with some server socket is only allowed to send messages to the server if the receive queue of this socket contains at most sk_max_ack_backlog datagrams. This implies that prospective writers might be forced to go to sleep despite none of the message presently enqueued on the server receive queue were sent by them. In order to ensure that these will be woken up once space becomes again available, the present unix_dgram_poll routine does a second sock_poll_wait call with the peer_wait wait queue of the server socket as queue argument (unix_dgram_recvmsg does a wake up on this queue after a datagram was received). This is inherently problematic because the server socket is only guaranteed to remain alive for as long as the client still holds a reference to it. In case the connection is dissolved via connect or by the dead peer detection logic in unix_dgram_sendmsg, the server socket may be freed despite "the polling mechanism" (in particular, epoll) still has a pointer to the corresponding peer_wait queue. There's no way to forcibly deregister a wait queue with epoll. Based on an idea by Jason Baron, the patch below changes the code such that a wait_queue_t belonging to the client socket is enqueued on the peer_wait queue of the server whenever the peer receive queue full condition is detected by either a sendmsg or a poll. A wake up on the peer queue is then relayed to the ordinary wait queue of the client socket via wake function. The connection to the peer wait queue is again dissolved if either a wake up is about to be relayed or the client socket reconnects or a dead peer is detected or the client socket is itself closed. This enables removing the second sock_poll_wait from unix_dgram_poll, thus avoiding the use-after-free, while still ensuring that no blocked writer sleeps forever. Signed-off-by: Rainer Weikusat <[email protected]> Fixes: ec0d215f9420 ("af_unix: fix 'poll for write'/connected DGRAM sockets") Reviewed-by: Jason Baron <[email protected]> Signed-off-by: David S. Miller <[email protected]>
int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) { ASN1_VALUE **opval = NULL; ASN1_STRING *stmp; ASN1_TYPE *typ = NULL; int ret = 0; const ASN1_PRIMITIVE_FUNCS *pf; ASN1_INTEGER **tint; pf = it->funcs; if (pf && pf->prim_c2i) return pf->prim_c2i(pval, cont, len, utype, free_cont, it); /* If ANY type clear type and set pointer to internal value */ if (it->utype == V_ASN1_ANY) { if (!*pval) { typ = ASN1_TYPE_new(); if (typ == NULL) goto err; *pval = (ASN1_VALUE *)typ; } else typ = (ASN1_TYPE *)*pval; if (utype != typ->type) ASN1_TYPE_set(typ, utype, NULL); opval = pval; pval = &typ->value.asn1_value; } switch (utype) { case V_ASN1_OBJECT: if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)) goto err; break; case V_ASN1_NULL: if (len) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_NULL_IS_WRONG_LENGTH); goto err; } *pval = (ASN1_VALUE *)1; break; case V_ASN1_BOOLEAN: if (len != 1) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BOOLEAN_IS_WRONG_LENGTH); goto err; } else { ASN1_BOOLEAN *tbool; tbool = (ASN1_BOOLEAN *)pval; *tbool = *cont; } break; case V_ASN1_BIT_STRING: if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)) goto err; break; case V_ASN1_INTEGER: case V_ASN1_ENUMERATED: tint = (ASN1_INTEGER **)pval; if (!c2i_ASN1_INTEGER(tint, &cont, len)) goto err; /* Fixup type to match the expected form */ (*tint)->type = utype | ((*tint)->type & V_ASN1_NEG); break; case V_ASN1_OCTET_STRING: case V_ASN1_NUMERICSTRING: case V_ASN1_PRINTABLESTRING: case V_ASN1_T61STRING: case V_ASN1_VIDEOTEXSTRING: case V_ASN1_IA5STRING: case V_ASN1_UTCTIME: case V_ASN1_GENERALIZEDTIME: case V_ASN1_GRAPHICSTRING: case V_ASN1_VISIBLESTRING: case V_ASN1_GENERALSTRING: case V_ASN1_UNIVERSALSTRING: case V_ASN1_BMPSTRING: case V_ASN1_UTF8STRING: case V_ASN1_OTHER: case V_ASN1_SET: case V_ASN1_SEQUENCE: default: if (utype == V_ASN1_BMPSTRING && (len & 1)) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_BMPSTRING_IS_WRONG_LENGTH); goto err; } if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) { ASN1err(ASN1_F_ASN1_EX_C2I, ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH); goto err; } /* All based on ASN1_STRING and handled the same */ if (!*pval) { stmp = ASN1_STRING_type_new(utype); if (!stmp) { ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE); goto err; } *pval = (ASN1_VALUE *)stmp; } else { stmp = (ASN1_STRING *)*pval; stmp->type = utype; } /* If we've already allocated a buffer use it */ if (*free_cont) { if (stmp->data) OPENSSL_free(stmp->data); stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */ stmp->length = len; *free_cont = 0; } else { if (!ASN1_STRING_set(stmp, cont, len)) { ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE); ASN1_STRING_free(stmp); *pval = NULL; goto err; } } break; } /* If ASN1_ANY and NULL type fix up value */ if (typ && (utype == V_ASN1_NULL)) typ->value.ptr = NULL; ret = 1; err: if (!ret) { ASN1_TYPE_free(typ); if (opval) *opval = NULL; } return ret; }
0
[ "CWE-119" ]
openssl
f5da52e308a6aeea6d5f3df98c4da295d7e9cc27
195,565,156,246,533,850,000,000,000,000,000,000,000
136
Fix ASN1_INTEGER handling. Only treat an ASN1_ANY type as an integer if it has the V_ASN1_INTEGER tag: V_ASN1_NEG_INTEGER is an internal only value which is never used for on the wire encoding. Thanks to David Benjamin <[email protected]> for reporting this bug. This was found using libFuzzer. RT#4364 (part)CVE-2016-2108. Reviewed-by: Emilia Käsper <[email protected]>
static int no_givdecrypt(struct skcipher_givcrypt_request *req) { return -ENOSYS; }
0
[ "CWE-310" ]
linux
9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6
286,910,802,903,299,740,000,000,000,000,000,000,000
4
crypto: user - fix info leaks in report API Three errors resulting in kernel memory disclosure: 1/ The structures used for the netlink based crypto algorithm report API are located on the stack. As snprintf() does not fill the remainder of the buffer with null bytes, those stack bytes will be disclosed to users of the API. Switch to strncpy() to fix this. 2/ crypto_report_one() does not initialize all field of struct crypto_user_alg. Fix this to fix the heap info leak. 3/ For the module name we should copy only as many bytes as module_name() returns -- not as much as the destination buffer could hold. But the current code does not and therefore copies random data from behind the end of the module name, as the module name is always shorter than CRYPTO_MAX_ALG_NAME. Also switch to use strncpy() to copy the algorithm's name and driver_name. They are strings, after all. Signed-off-by: Mathias Krause <[email protected]> Cc: Steffen Klassert <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
NTSTATUS smbXcli_session_application_key(struct smbXcli_session *session, TALLOC_CTX *mem_ctx, DATA_BLOB *key) { const DATA_BLOB *application_key; *key = data_blob_null; if (session->conn == NULL) { return NT_STATUS_NO_USER_SESSION_KEY; } if (session->conn->protocol >= PROTOCOL_SMB2_02) { application_key = &session->smb2->application_key; } else { application_key = &session->smb1.application_key; } if (application_key->length == 0) { return NT_STATUS_NO_USER_SESSION_KEY; } *key = data_blob_dup_talloc(mem_ctx, *application_key); if (key->data == NULL) { return NT_STATUS_NO_MEMORY; } return NT_STATUS_OK; }
0
[ "CWE-20" ]
samba
a819d2b440aafa3138d95ff6e8b824da885a70e9
281,323,117,480,728,170,000,000,000,000,000,000,000
29
CVE-2015-5296: libcli/smb: make sure we require signing when we demand encryption on a session BUG: https://bugzilla.samba.org/show_bug.cgi?id=11536 Signed-off-by: Stefan Metzmacher <[email protected]> Reviewed-by: Jeremy Allison <[email protected]>
static void wifi_setup(struct net_device *dev) { dev->netdev_ops = &airo11_netdev_ops; dev->header_ops = &airo_header_ops; dev->wireless_handlers = &airo_handler_def; dev->type = ARPHRD_IEEE80211; dev->hard_header_len = ETH_HLEN; dev->mtu = AIRO_DEF_MTU; dev->addr_len = ETH_ALEN; dev->tx_queue_len = 100; memset(dev->broadcast,0xFF, ETH_ALEN); dev->flags = IFF_BROADCAST|IFF_MULTICAST; }
0
[ "CWE-703", "CWE-264" ]
linux
550fd08c2cebad61c548def135f67aba284c6162
67,614,798,301,842,320,000,000,000,000,000,000,000
16
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 <[email protected]> CC: Karsten Keil <[email protected]> CC: "David S. Miller" <[email protected]> CC: Jay Vosburgh <[email protected]> CC: Andy Gospodarek <[email protected]> CC: Patrick McHardy <[email protected]> CC: Krzysztof Halasa <[email protected]> CC: "John W. Linville" <[email protected]> CC: Greg Kroah-Hartman <[email protected]> CC: Marcel Holtmann <[email protected]> CC: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static inline unsigned int memalloc_nocma_save(void) { unsigned int flags = current->flags & PF_MEMALLOC_NOCMA; current->flags |= PF_MEMALLOC_NOCMA; return flags; }
0
[ "CWE-362", "CWE-703", "CWE-667" ]
linux
04f5866e41fb70690e28397487d8bd8eea7d712a
36,693,692,556,136,763,000,000,000,000,000,000,000
7
coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping The core dumping code has always run without holding the mmap_sem for writing, despite that is the only way to ensure that the entire vma layout will not change from under it. Only using some signal serialization on the processes belonging to the mm is not nearly enough. This was pointed out earlier. For example in Hugh's post from Jul 2017: https://lkml.kernel.org/r/[email protected] "Not strictly relevant here, but a related note: I was very surprised to discover, only quite recently, how handle_mm_fault() may be called without down_read(mmap_sem) - when core dumping. That seems a misguided optimization to me, which would also be nice to correct" In particular because the growsdown and growsup can move the vm_start/vm_end the various loops the core dump does around the vma will not be consistent if page faults can happen concurrently. Pretty much all users calling mmget_not_zero()/get_task_mm() and then taking the mmap_sem had the potential to introduce unexpected side effects in the core dumping code. Adding mmap_sem for writing around the ->core_dump invocation is a viable long term fix, but it requires removing all copy user and page faults and to replace them with get_dump_page() for all binary formats which is not suitable as a short term fix. For the time being this solution manually covers the places that can confuse the core dump either by altering the vma layout or the vma flags while it runs. Once ->core_dump runs under mmap_sem for writing the function mmget_still_valid() can be dropped. Allowing mmap_sem protected sections to run in parallel with the coredump provides some minor parallelism advantage to the swapoff code (which seems to be safe enough by never mangling any vma field and can keep doing swapins in parallel to the core dumping) and to some other corner case. In order to facilitate the backporting I added "Fixes: 86039bd3b4e6" however the side effect of this same race condition in /proc/pid/mem should be reproducible since before 2.6.12-rc2 so I couldn't add any other "Fixes:" because there's no hash beyond the git genesis commit. Because find_extend_vma() is the only location outside of the process context that could modify the "mm" structures under mmap_sem for reading, by adding the mmget_still_valid() check to it, all other cases that take the mmap_sem for reading don't need the new check after mmget_not_zero()/get_task_mm(). The expand_stack() in page fault context also doesn't need the new check, because all tasks under core dumping are frozen. Link: http://lkml.kernel.org/r/[email protected] Fixes: 86039bd3b4e6 ("userfaultfd: add new syscall to provide memory externalization") Signed-off-by: Andrea Arcangeli <[email protected]> Reported-by: Jann Horn <[email protected]> Suggested-by: Oleg Nesterov <[email protected]> Acked-by: Peter Xu <[email protected]> Reviewed-by: Mike Rapoport <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Reviewed-by: Jann Horn <[email protected]> Acked-by: Jason Gunthorpe <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
new_fixup(struct archive_write_disk *a, const char *pathname) { struct fixup_entry *fe; fe = (struct fixup_entry *)calloc(1, sizeof(struct fixup_entry)); if (fe == NULL) { archive_set_error(&a->archive, ENOMEM, "Can't allocate memory for a fixup"); return (NULL); } fe->next = a->fixup_list; a->fixup_list = fe; fe->fixup = 0; fe->filetype = 0; fe->name = strdup(pathname); return (fe); }
0
[ "CWE-59" ]
libarchive
ede459d2ebb879f5eedb6f7abea203be0b334230
326,267,987,829,233,060,000,000,000,000,000,000,000
17
archive_write_disk_posix: fix writing fflags broken in 8a1bd5c The fixup list was erroneously assumed to be directories only. Only in the case of critical file flags modification (e.g. SF_IMMUTABLE on BSD systems), other file types (e.g. regular files or symbolic links) may be added to the fixup list. We still need to verify that we are writing to the correct file type, so compare the archive entry file type with the file type of the file to be modified. Fixes #1617
Version ModuleSQL::GetVersion() { return Version("MySQL support", VF_VENDOR); }
0
[ "CWE-476" ]
inspircd
2cc35d8625b7ea5cbd1d1ebb116aff86c5280162
82,437,578,886,706,790,000,000,000,000,000,000,000
4
Initialise and deallocate the MySQL library correctly.
inotify_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt) { return get_sb_pseudo(fs_type, "inotify", NULL, INOTIFYFS_SUPER_MAGIC, mnt); }
0
[ "CWE-399" ]
linux-2.6
3632dee2f8b8a9720329f29eeaa4ec4669a3aff8
153,453,123,202,235,340,000,000,000,000,000,000,000
6
inotify: clean up inotify_read and fix locking problems If userspace supplies an invalid pointer to a read() of an inotify instance, the inotify device's event list mutex is unlocked twice. This causes an unbalance which effectively leaves the data structure unprotected, and we can trigger oopses by accessing the inotify instance from different tasks concurrently. The best fix (contributed largely by Linus) is a total rewrite of the function in question: On Thu, Jan 22, 2009 at 7:05 AM, Linus Torvalds wrote: > The thing to notice is that: > > - locking is done in just one place, and there is no question about it > not having an unlock. > > - that whole double-while(1)-loop thing is gone. > > - use multiple functions to make nesting and error handling sane > > - do error testing after doing the things you always need to do, ie do > this: > > mutex_lock(..) > ret = function_call(); > mutex_unlock(..) > > .. test ret here .. > > instead of doing conditional exits with unlocking or freeing. > > So if the code is written in this way, it may still be buggy, but at least > it's not buggy because of subtle "forgot to unlock" or "forgot to free" > issues. > > This _always_ unlocks if it locked, and it always frees if it got a > non-error kevent. Cc: John McCutchan <[email protected]> Cc: Robert Love <[email protected]> Cc: <[email protected]> Signed-off-by: Vegard Nossum <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
int fp_mod(fp_int *a, fp_int *b, fp_int *c) { #ifndef WOLFSSL_SMALL_STACK fp_int t[1]; #else fp_int *t; #endif int err; #ifdef WOLFSSL_SMALL_STACK t = (fp_int*)XMALLOC(sizeof(fp_int), NULL, DYNAMIC_TYPE_BIGINT); if (t == NULL) return FP_MEM; #endif fp_init(t); err = fp_div(a, b, NULL, t); if (err == FP_OKAY) { if (t->sign != b->sign) { fp_add(t, b, c); } else { fp_copy(t, c); } } #ifdef WOLFSSL_SMALL_STACK XFREE(t, NULL, DYNAMIC_TYPE_BIGINT); #endif return err; }
0
[ "CWE-326", "CWE-203" ]
wolfssl
1de07da61f0c8e9926dcbd68119f73230dae283f
296,428,070,279,598,530,000,000,000,000,000,000,000
30
Constant time EC map to affine for private operations For fast math, use a constant time modular inverse when mapping to affine when operation involves a private key - key gen, calc shared secret, sign.
HttpTransact::url_looks_dynamic(URL* url) { const char *p_start, *p, *t; static const char *asp = ".asp"; const char *part; int part_length; if (url->scheme_get_wksidx() != URL_WKSIDX_HTTP && url->scheme_get_wksidx() != URL_WKSIDX_HTTPS) { return false; } //////////////////////////////////////////////////////////// // (1) If URL contains query stuff in it, call it dynamic // //////////////////////////////////////////////////////////// part = url->params_get(&part_length); if (part != NULL) { return true; } part = url->query_get(&part_length); if (part != NULL) { return true; } /////////////////////////////////////////////// // (2) If path ends in "asp" call it dynamic // /////////////////////////////////////////////// part = url->path_get(&part_length); if (part) { p = &part[part_length - 1]; t = &asp[3]; while (p != part) { if (ParseRules::ink_tolower(*p) == ParseRules::ink_tolower(*t)) { p -= 1; t -= 1; if (t == asp) return true; } else break; } } ///////////////////////////////////////////////////////////////// // (3) If the path of the url contains "cgi", call it dynamic. // ///////////////////////////////////////////////////////////////// if (part && part_length >= 3) { for (p_start = part; p_start <= &part[part_length - 3]; p_start++) { if (((p_start[0] == 'c') || (p_start[0] == 'C')) && ((p_start[1] == 'g') || (p_start[1] == 'G')) && ((p_start[2] == 'i') || (p_start[2] == 'I'))) { return (true); } } } return (false); }
0
[ "CWE-119" ]
trafficserver
8b5f0345dade6b2822d9b52c8ad12e63011a5c12
83,149,053,575,208,950,000,000,000,000,000,000,000
56
Fix the internal buffer sizing. Thanks to Sudheer for helping isolating this bug
GF_Err gf_isom_remove_track_protection(GF_ISOFile *the_file, u32 trackNumber, u32 sampleDescriptionIndex) { GF_TrackBox *trak; GF_Err e; GF_SampleEntryBox *sea; GF_ProtectionSchemeInfoBox *sinf; e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !sampleDescriptionIndex) return GF_BAD_PARAM; sea = NULL; sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CENC_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CBC_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CENS_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CBCS_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_ISMACRYP_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_OMADRM_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_ADOBE_SCHEME, &sea); if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_PIFF_SCHEME, &sea); if (!sinf) return GF_OK; sea->type = sinf->original_format->data_format; while (1) { GF_Box *b = gf_isom_box_find_child(sea->child_boxes, GF_ISOM_BOX_TYPE_SINF); if (!b) break; gf_isom_box_del_parent(&sea->child_boxes, b); } if (sea->type == GF_ISOM_BOX_TYPE_264B) sea->type = GF_ISOM_BOX_TYPE_AVC1; if (sea->type == GF_ISOM_BOX_TYPE_265B) sea->type = GF_ISOM_BOX_TYPE_HVC1; return GF_OK; }
0
[ "CWE-476" ]
gpac
3b84ffcbacf144ce35650df958432f472b6483f8
93,159,486,559,622,070,000,000,000,000,000,000,000
34
fixed #1735
cr_input_get_cur_pos (CRInput const * a_this, CRInputPos * a_pos) { g_return_val_if_fail (a_this && PRIVATE (a_this) && a_pos, CR_BAD_PARAM_ERROR); a_pos->next_byte_index = PRIVATE (a_this)->next_byte_index; a_pos->line = PRIVATE (a_this)->line; a_pos->col = PRIVATE (a_this)->col; a_pos->end_of_line = PRIVATE (a_this)->end_of_line; a_pos->end_of_file = PRIVATE (a_this)->end_of_input; return CR_OK; }
0
[ "CWE-125" ]
libcroco
898e3a8c8c0314d2e6b106809a8e3e93cf9d4394
46,564,750,110,146,320,000,000,000,000,000,000,000
13
input: check end of input before reading a byte When reading bytes we weren't check that the index wasn't out of bound and this could produce an invalid read which could deal to a security bug.
http_client_check_data_free (gpointer user_data) { CheckData *data = user_data; if (data->cancellable_id > 0) { g_cancellable_disconnect (data->cancellable, data->cancellable_id); g_object_unref (data->cancellable); } /* soup_session_queue_message stole the references to data->msg */ g_object_unref (data->res); g_object_unref (data->session); g_slice_free (CheckData, data); return G_SOURCE_REMOVE; }
0
[ "CWE-310" ]
gnome-online-accounts
edde7c63326242a60a075341d3fea0be0bc4d80e
168,343,778,933,193,930,000,000,000,000,000,000,000
17
Guard against invalid SSL certificates None of the branded providers (eg., Google, Facebook and Windows Live) should ever have an invalid certificate. So set "ssl-strict" on the SoupSession object being used by GoaWebView. Providers like ownCloud and Exchange might have to deal with certificates that are not up to the mark. eg., self-signed certificates. For those, show a warning when the account is being created, and only proceed if the user decides to ignore it. In any case, save the status of the certificate that was used to create the account. So an account created with a valid certificate will never work with an invalid one, and one created with an invalid certificate will not throw any further warnings. Fixes: CVE-2013-0240
static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err) { const char *path; unsigned int mode, len; if (size < 23 || buf[size - 21]) { strbuf_addstr(err, _("too-short tree object")); return -1; } path = get_mode(buf, &mode); if (!path) { strbuf_addstr(err, _("malformed mode in tree entry")); return -1; } if (!*path) { strbuf_addstr(err, _("empty filename in tree entry")); return -1; } len = strlen(path) + 1; /* Initialize the descriptor entry */ desc->entry.path = path; desc->entry.mode = canon_mode(mode); desc->entry.oid = (const struct object_id *)(path + len); return 0; }
1
[ "CWE-20" ]
git
e1d911dd4c7b76a5a8cec0f5c8de15981e34da83
44,062,033,398,795,080,000,000,000,000,000,000,000
28
mingw: disallow backslash characters in tree objects' file names The backslash character is not a valid part of a file name on Windows. Hence it is dangerous to allow writing files that were unpacked from tree objects, when the stored file name contains a backslash character: it will be misinterpreted as directory separator. This not only causes ambiguity when a tree contains a blob `a\b` and a tree `a` that contains a blob `b`, but it also can be used as part of an attack vector to side-step the careful protections against writing into the `.git/` directory during a clone of a maliciously-crafted repository. Let's prevent that, addressing CVE-2019-1354. Note: we guard against backslash characters in tree objects' file names _only_ on Windows (because on other platforms, even on those where NTFS volumes can be mounted, the backslash character is _not_ a directory separator), and _only_ when `core.protectNTFS = true` (because users might need to generate tree objects for other platforms, of course without touching the worktree, e.g. using `git update-index --cacheinfo`). Signed-off-by: Johannes Schindelin <[email protected]>
static void kvm_vcpu_post_transition(struct kvm_vcpu *vcpu) { kvm_purge_vmm_mapping(vcpu); vti_set_rr6(vcpu->arch.host_rr6); }
0
[ "CWE-399" ]
kvm
5b40572ed5f0344b9dbee486a17c589ce1abe1a3
299,839,782,936,546,820,000,000,000,000,000,000,000
5
KVM: Ensure all vcpus are consistent with in-kernel irqchip settings If some vcpus are created before KVM_CREATE_IRQCHIP, then irqchip_in_kernel() and vcpu->arch.apic will be inconsistent, leading to potential NULL pointer dereferences. Fix by: - ensuring that no vcpus are installed when KVM_CREATE_IRQCHIP is called - ensuring that a vcpu has an apic if it is installed after KVM_CREATE_IRQCHIP This is somewhat long winded because vcpu->arch.apic is created without kvm->lock held. Based on earlier patch by Michael Ellerman. Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
static void __exit crypto_user_exit(void) { netlink_kernel_release(crypto_nlsk); }
0
[ "CWE-264" ]
net
90f62cf30a78721641e08737bda787552428061e
230,992,885,895,403,050,000,000,000,000,000,000,000
4
net: Use netlink_ns_capable to verify the permisions of netlink messages It is possible by passing a netlink socket to a more privileged executable and then to fool that executable into writing to the socket data that happens to be valid netlink message to do something that privileged executable did not intend to do. To keep this from happening replace bare capable and ns_capable calls with netlink_capable, netlink_net_calls and netlink_ns_capable calls. Which act the same as the previous calls except they verify that the opener of the socket had the desired permissions as well. Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
TEST_F(QueryPlannerTest, MultikeySharedPrefixTwoElemMatches) { // true means multikey addIndex(BSON("a.b" << 1 << "a.c" << 1), true); runQuery(fromjson("{$and: [{a: {$elemMatch: {b: 1}}}, {a: {$elemMatch: {c: 1}}}]}")); assertNumSolutions(2U); assertSolutionExists("{cscan: {dir: 1}}"); assertSolutionExists( "{fetch: {node: {ixscan: {pattern: {'a.b':1,'a.c':1}, bounds: " "{'a.b': [[1,1,true,true]], " " 'a.c': [['MinKey','MaxKey',true,true]]}}}}}"); }
0
[ "CWE-834" ]
mongo
94d0e046baa64d1aa1a6af97e2d19bb466cc1ff5
185,368,161,327,442,430,000,000,000,000,000,000,000
12
SERVER-38164 $or pushdown optimization does not correctly handle $not within an $elemMatch
static int parsePostRead ( Operation *op, SlapReply *rs, LDAPControl *ctrl ) { return parseReadAttrs( op, rs, ctrl, 1 ); }
0
[ "CWE-125" ]
openldap
21981053a1195ae1555e23df4d9ac68d34ede9dd
13,510,898,827,019,860,000,000,000,000,000,000,000
7
ITS#9408 fix vrfilter double-free
static int nft_flush_table(struct nft_ctx *ctx) { int err; struct nft_chain *chain, *nc; struct nft_set *set, *ns; list_for_each_entry(chain, &ctx->table->chains, list) { ctx->chain = chain; err = nft_delrule_by_chain(ctx); if (err < 0) goto out; } list_for_each_entry_safe(set, ns, &ctx->table->sets, list) { if (set->flags & NFT_SET_ANONYMOUS && !list_empty(&set->bindings)) continue; err = nft_delset(ctx, set); if (err < 0) goto out; } list_for_each_entry_safe(chain, nc, &ctx->table->chains, list) { ctx->chain = chain; err = nft_delchain(ctx); if (err < 0) goto out; } err = nft_deltable(ctx); out: return err; }
0
[ "CWE-19" ]
nf
a2f18db0c68fec96631c10cad9384c196e9008ac
1,451,503,721,397,273,000,000,000,000,000,000,000
36
netfilter: nf_tables: fix flush ruleset chain dependencies Jumping between chains doesn't mix well with flush ruleset. Rules from a different chain and set elements may still refer to us. [ 353.373791] ------------[ cut here ]------------ [ 353.373845] kernel BUG at net/netfilter/nf_tables_api.c:1159! [ 353.373896] invalid opcode: 0000 [#1] SMP [ 353.373942] Modules linked in: intel_powerclamp uas iwldvm iwlwifi [ 353.374017] CPU: 0 PID: 6445 Comm: 31c3.nft Not tainted 3.18.0 #98 [ 353.374069] Hardware name: LENOVO 5129CTO/5129CTO, BIOS 6QET47WW (1.17 ) 07/14/2010 [...] [ 353.375018] Call Trace: [ 353.375046] [<ffffffff81964c31>] ? nf_tables_commit+0x381/0x540 [ 353.375101] [<ffffffff81949118>] nfnetlink_rcv+0x3d8/0x4b0 [ 353.375150] [<ffffffff81943fc5>] netlink_unicast+0x105/0x1a0 [ 353.375200] [<ffffffff8194438e>] netlink_sendmsg+0x32e/0x790 [ 353.375253] [<ffffffff818f398e>] sock_sendmsg+0x8e/0xc0 [ 353.375300] [<ffffffff818f36b9>] ? move_addr_to_kernel.part.20+0x19/0x70 [ 353.375357] [<ffffffff818f44f9>] ? move_addr_to_kernel+0x19/0x30 [ 353.375410] [<ffffffff819016d2>] ? verify_iovec+0x42/0xd0 [ 353.375459] [<ffffffff818f3e10>] ___sys_sendmsg+0x3f0/0x400 [ 353.375510] [<ffffffff810615fa>] ? native_sched_clock+0x2a/0x90 [ 353.375563] [<ffffffff81176697>] ? acct_account_cputime+0x17/0x20 [ 353.375616] [<ffffffff8110dc78>] ? account_user_time+0x88/0xa0 [ 353.375667] [<ffffffff818f4bbd>] __sys_sendmsg+0x3d/0x80 [ 353.375719] [<ffffffff81b184f4>] ? int_check_syscall_exit_work+0x34/0x3d [ 353.375776] [<ffffffff818f4c0d>] SyS_sendmsg+0xd/0x20 [ 353.375823] [<ffffffff81b1826d>] system_call_fastpath+0x16/0x1b Release objects in this order: rules -> sets -> chains -> tables, to make sure no references to chains are held anymore. Reported-by: Asbjoern Sloth Toennesen <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
mbfl_encoding_detector_delete(mbfl_encoding_detector *identd) { int i; if (identd != NULL) { if (identd->filter_list != NULL) { i = identd->filter_list_size; while (i > 0) { i--; mbfl_identify_filter_delete(identd->filter_list[i]); } mbfl_free((void *)identd->filter_list); } mbfl_free((void *)identd); } }
0
[ "CWE-119" ]
php-src
64f42c73efc58e88671ad76b6b6bc8e2b62713e1
340,119,244,762,770,350,000,000,000,000,000,000,000
16
Fixed bug #71906: AddressSanitizer: negative-size-param (-1) in mbfl_strcut
void ssl_set_session_cache( ssl_context *ssl, int (*f_get_cache)(void *, ssl_session *), void *p_get_cache, int (*f_set_cache)(void *, const ssl_session *), void *p_set_cache ) { ssl->f_get_cache = f_get_cache; ssl->p_get_cache = p_get_cache; ssl->f_set_cache = f_set_cache; ssl->p_set_cache = p_set_cache; }
0
[ "CWE-310" ]
polarssl
4582999be608c9794d4518ae336b265084db9f93
25,744,553,337,074,660,000,000,000,000,000,000,000
9
Fixed timing difference resulting from badly formatted padding.
static int ext4_validate_inode_bitmap(struct super_block *sb, struct ext4_group_desc *desc, ext4_group_t block_group, struct buffer_head *bh) { ext4_fsblk_t blk; struct ext4_group_info *grp = ext4_get_group_info(sb, block_group); if (buffer_verified(bh)) return 0; if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) return -EFSCORRUPTED; ext4_lock_group(sb, block_group); blk = ext4_inode_bitmap(sb, desc); if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh, EXT4_INODES_PER_GROUP(sb) / 8)) { ext4_unlock_group(sb, block_group); ext4_error(sb, "Corrupt inode bitmap - block_group = %u, " "inode_bitmap = %llu", block_group, blk); ext4_mark_group_bitmap_corrupted(sb, block_group, EXT4_GROUP_INFO_IBITMAP_CORRUPT); return -EFSBADCRC; } set_buffer_verified(bh); ext4_unlock_group(sb, block_group); return 0; }
0
[ "CWE-416" ]
linux
8844618d8aa7a9973e7b527d038a2a589665002c
277,451,188,338,052,400,000,000,000,000,000,000,000
28
ext4: only look at the bg_flags field if it is valid The bg_flags field in the block group descripts is only valid if the uninit_bg or metadata_csum feature is enabled. We were not consistently looking at this field; fix this. Also block group #0 must never have uninitialized allocation bitmaps, or need to be zeroed, since that's where the root inode, and other special inodes are set up. Check for these conditions and mark the file system as corrupted if they are detected. This addresses CVE-2018-10876. https://bugzilla.kernel.org/show_bug.cgi?id=199403 Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
void usbip_dump_urb(struct urb *urb) { struct device *dev; if (!urb) { pr_debug("urb: null pointer!!\n"); return; } if (!urb->dev) { pr_debug("urb->dev: null pointer!!\n"); return; } dev = &urb->dev->dev; dev_dbg(dev, " urb :%p\n", urb); dev_dbg(dev, " dev :%p\n", urb->dev); usbip_dump_usb_device(urb->dev); dev_dbg(dev, " pipe :%08x ", urb->pipe); usbip_dump_pipe(urb->pipe); dev_dbg(dev, " status :%d\n", urb->status); dev_dbg(dev, " transfer_flags :%08X\n", urb->transfer_flags); dev_dbg(dev, " transfer_buffer :%p\n", urb->transfer_buffer); dev_dbg(dev, " transfer_buffer_length:%d\n", urb->transfer_buffer_length); dev_dbg(dev, " actual_length :%d\n", urb->actual_length); dev_dbg(dev, " setup_packet :%p\n", urb->setup_packet); if (urb->setup_packet && usb_pipetype(urb->pipe) == PIPE_CONTROL) usbip_dump_usb_ctrlrequest( (struct usb_ctrlrequest *)urb->setup_packet); dev_dbg(dev, " start_frame :%d\n", urb->start_frame); dev_dbg(dev, " number_of_packets :%d\n", urb->number_of_packets); dev_dbg(dev, " interval :%d\n", urb->interval); dev_dbg(dev, " error_count :%d\n", urb->error_count); dev_dbg(dev, " context :%p\n", urb->context); dev_dbg(dev, " complete :%p\n", urb->complete); }
0
[ "CWE-200", "CWE-119" ]
linux
b348d7dddb6c4fbfc810b7a0626e8ec9e29f7cbb
14,528,534,407,017,597,000,000,000,000,000,000,000
44
USB: usbip: fix potential out-of-bounds write Fix potential out-of-bounds write to urb->transfer_buffer usbip handles network communication directly in the kernel. When receiving a packet from its peer, usbip code parses headers according to protocol. As part of this parsing urb->actual_length is filled. Since the input for urb->actual_length comes from the network, it should be treated as untrusted. Any entity controlling the network may put any value in the input and the preallocated urb->transfer_buffer may not be large enough to hold the data. Thus, the malicious entity is able to write arbitrary data to kernel memory. Signed-off-by: Ignat Korchagin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static void test_wl4435_2() { MYSQL_STMT *stmt; int i; int rc; char query[MAX_TEST_QUERY_LENGTH]; myheader("test_wl4435_2"); mct_start_logging("test_wl4435_2"); /* Do a few iterations so that we catch any problem with incorrect handling/flushing prepared statement results. */ for (i= 0; i < 10; ++i) { /* Prepare a procedure. That can be moved out of the loop, but it was left in the loop for the sake of having as many statements as possible. */ rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1"); myquery(rc); rc= mysql_query(mysql, "CREATE PROCEDURE p1()" "BEGIN " " SELECT 1; " " SELECT 2, 3 UNION SELECT 4, 5; " " SELECT 6, 7, 8; " "END"); myquery(rc); /* Invoke a procedure, that returns several result sets. */ my_stpcpy(query, "CALL p1()"); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); /* Execute! */ rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); /* Flush all the results. */ mysql_stmt_close(stmt); /* Clean up. */ rc= mysql_commit(mysql); myquery(rc); rc= mysql_query(mysql, "DROP PROCEDURE p1"); myquery(rc); } mct_close_log(); }
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
249,445,092,581,157,100,000,000,000,000,000,000,000
59
WL#6791 : Redefine client --ssl option to imply enforced encryption # Changed the meaning of the --ssl=1 option of all client binaries to mean force ssl, not try ssl and fail over to eunecrypted # Added a new MYSQL_OPT_SSL_ENFORCE mysql_options() option to specify that an ssl connection is required. # Added a new macro SSL_SET_OPTIONS() to the client SSL handling headers that sets all the relevant SSL options at once. # Revamped all of the current native clients to use the new macro # Removed some Windows line endings. # Added proper handling of the new option into the ssl helper headers. # If SSL is mandatory assume that the media is secure enough for the sha256 plugin to do unencrypted password exchange even before establishing a connection. # Set the default ssl cipher to DHE-RSA-AES256-SHA if none is specified. # updated test cases that require a non-default cipher to spawn a mysql command line tool binary since mysqltest has no support for specifying ciphers. # updated the replication slave connection code to always enforce SSL if any of the SSL config options is present. # test cases added and updated. # added a mysql_get_option() API to return mysql_options() values. Used the new API inside the sha256 plugin. # Fixed compilation warnings because of unused variables. # Fixed test failures (mysql_ssl and bug13115401) # Fixed whitespace issues. # Fully implemented the mysql_get_option() function. # Added a test case for mysql_get_option() # fixed some trailing whitespace issues # fixed some uint/int warnings in mysql_client_test.c # removed shared memory option from non-windows get_options tests # moved MYSQL_OPT_LOCAL_INFILE to the uint options
tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, struct rtattr *rate_tlv, struct tcf_exts *exts, struct tcf_ext_map *map) { memset(exts, 0, sizeof(*exts)); #ifdef CONFIG_NET_CLS_ACT { int err; struct tc_action *act; if (map->police && tb[map->police-1]) { act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police", TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); if (act == NULL) return err; act->type = TCA_OLD_COMPAT; exts->action = act; } else if (map->action && tb[map->action-1]) { act = tcf_action_init(tb[map->action-1], rate_tlv, NULL, TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); if (act == NULL) return err; exts->action = act; } } #elif defined CONFIG_NET_CLS_POLICE if (map->police && tb[map->police-1]) { struct tcf_police *p; p = tcf_police_locate(tb[map->police-1], rate_tlv); if (p == NULL) return -EINVAL; exts->police = p; } else if (map->action && tb[map->action-1]) return -EOPNOTSUPP; #else if ((map->action && tb[map->action-1]) || (map->police && tb[map->police-1])) return -EOPNOTSUPP; #endif return 0; }
0
[ "CWE-200" ]
linux-2.6
9ef1d4c7c7aca1cd436612b6ca785b726ffb8ed8
311,313,245,196,665,670,000,000,000,000,000,000,000
47
[NETLINK]: Missing initializations in dumped data Mostly missing initialization of padding fields of 1 or 2 bytes length, two instances of uninitialized nlmsgerr->msg of 16 bytes length. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static u32 tg3_read_otp_phycfg(struct tg3 *tp) { u32 bhalf_otp, thalf_otp; tw32(OTP_MODE, OTP_MODE_OTP_THRU_GRC); if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_INIT)) return 0; tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC1); if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ)) return 0; thalf_otp = tr32(OTP_READ_DATA); tw32(OTP_ADDRESS, OTP_ADDRESS_MAGIC2); if (tg3_issue_otp_command(tp, OTP_CTRL_OTP_CMD_READ)) return 0; bhalf_otp = tr32(OTP_READ_DATA); return ((thalf_otp & 0x0000ffff) << 16) | (bhalf_otp >> 16); }
0
[ "CWE-476", "CWE-119" ]
linux
715230a44310a8cf66fbfb5a46f9a62a9b2de424
252,842,835,478,938,200,000,000,000,000,000,000,000
25
tg3: fix length overflow in VPD firmware parsing Commit 184b89044fb6e2a74611dafa69b1dce0d98612c6 ("tg3: Use VPD fw version when present") introduced VPD parsing that contained a potential length overflow. Limit the hardware's reported firmware string length (max 255 bytes) to stay inside the driver's firmware string length (32 bytes). On overflow, truncate the formatted firmware string instead of potentially overwriting portions of the tg3 struct. http://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdf Signed-off-by: Kees Cook <[email protected]> Reported-by: Oded Horovitz <[email protected]> Reported-by: Brad Spengler <[email protected]> Cc: [email protected] Cc: Matt Carlson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int lua_ivm_set(lua_State *L) { const char *key, *raw_key; const char *value = NULL; apr_pool_t *pool; size_t str_len; lua_ivm_object *object = NULL; request_rec *r = ap_lua_check_request_rec(L, 1); key = luaL_checkstring(L, 2); luaL_checkany(L, 3); raw_key = apr_pstrcat(r->pool, "lua_ivm_", key, NULL); apr_global_mutex_lock(lua_ivm_mutex); pool = *((apr_pool_t**) apr_shm_baseaddr_get(lua_ivm_shm)); apr_pool_userdata_get((void **)&object, raw_key, pool); if (!object) { object = apr_pcalloc(pool, sizeof(lua_ivm_object)); ap_varbuf_init(pool, &object->vb, 2); object->size = 1; object->vb_size = 1; } object->type = lua_type(L, 3); if (object->type == LUA_TNUMBER) object->number = lua_tonumber(L, 3); else if (object->type == LUA_TBOOLEAN) object->number = lua_tonumber(L, 3); else if (object->type == LUA_TSTRING) { value = lua_tolstring(L, 3, &str_len); str_len++; /* add trailing \0 */ if ( str_len > object->vb_size) { ap_varbuf_grow(&object->vb, str_len); object->vb_size = str_len; } object->size = str_len-1; memset(object->vb.buf, 0, str_len); memcpy(object->vb.buf, value, str_len-1); } apr_pool_userdata_set(object, raw_key, NULL, pool); apr_global_mutex_unlock(lua_ivm_mutex); return 0; }
0
[ "CWE-20" ]
httpd
78eb3b9235515652ed141353d98c239237030410
288,211,369,453,013,780,000,000,000,000,000,000,000
39
*) SECURITY: CVE-2015-0228 (cve.mitre.org) mod_lua: A maliciously crafted websockets PING after a script calls r:wsupgrade() can cause a child process crash. [Edward Lu <Chaosed0 gmail.com>] Discovered by Guido Vranken <guidovranken gmail.com> Submitted by: Edward Lu Committed by: covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1657261 13f79535-47bb-0310-9956-ffa450edef68
static void tcm_loop_set_default_node_attributes(struct se_node_acl *se_acl) { return; }
0
[ "CWE-119", "CWE-787" ]
linux
12f09ccb4612734a53e47ed5302e0479c10a50f8
86,130,319,973,246,690,000,000,000,000,000,000,000
4
loopback: off by one in tcm_loop_make_naa_tpg() This is an off by one 'tgpt' check in tcm_loop_make_naa_tpg() that could result in memory corruption. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Nicholas A. Bellinger <[email protected]>
int gnutls_x509_aki_init(gnutls_x509_aki_t * aki) { *aki = gnutls_calloc(1, sizeof(struct gnutls_x509_aki_st)); if (*aki == NULL) return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR); return 0; }
0
[]
gnutls
d6972be33264ecc49a86cd0958209cd7363af1e9
54,780,658,928,203,610,000,000,000,000,000,000,000
8
eliminated double-free in the parsing of dist points Reported by Robert Święcki.
static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) { unsigned char buffer[2]; if (-1 == subaddr) { v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", chip->c->name, val); chip->shadow.bytes[1] = val; buffer[0] = val; if (1 != i2c_master_send(chip->c,buffer,1)) { v4l_warn(chip->c, "%s: I/O error (write 0x%x)\n", chip->c->name, val); return -1; } } else { v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", chip->c->name, subaddr, val); chip->shadow.bytes[subaddr+1] = val; buffer[0] = subaddr; buffer[1] = val; if (2 != i2c_master_send(chip->c,buffer,2)) { v4l_warn(chip->c, "%s: I/O error (write reg%d=0x%x)\n", chip->c->name, subaddr, val); return -1; } } return 0; }
1
[]
linux-2.6
494264379d186bf806613d27aafb7d88d42f4212
101,476,711,595,109,130,000,000,000,000,000,000,000
28
V4L/DVB (9621): Avoid writing outside shadow.bytes[] array There were no check about the limits of shadow.bytes array. This offers a risk of writing values outside the limits, overriding other data areas. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) { xmlNsPtr ns; xmlChar* fixed; if (cur == NULL) return; switch(cur->type) { case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_FRAG_NODE: case XML_NOTATION_NODE: case XML_DTD_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_PI_NODE: case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: case XML_NAMESPACE_DECL: case XML_XINCLUDE_START: case XML_XINCLUDE_END: return; case XML_ELEMENT_NODE: case XML_ATTRIBUTE_NODE: break; case XML_DOCUMENT_NODE: case XML_HTML_DOCUMENT_NODE: { xmlDocPtr doc = (xmlDocPtr) cur; if (doc->URL != NULL) xmlFree((xmlChar *) doc->URL); if (uri == NULL) doc->URL = NULL; else doc->URL = xmlPathToURI(uri); return; } } ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE); if (ns == NULL) return; fixed = xmlPathToURI(uri); if (fixed != NULL) { xmlSetNsProp(cur, ns, BAD_CAST "base", fixed); xmlFree(fixed); } else { xmlSetNsProp(cur, ns, BAD_CAST "base", uri); } }
0
[ "CWE-190" ]
libxml2
6c283d83eccd940bcde15634ac8c7f100e3caefd
96,731,956,740,234,430,000,000,000,000,000,000,000
51
[CVE-2022-29824] Fix integer overflows in xmlBuf and xmlBuffer In several places, the code handling string buffers didn't check for integer overflow or used wrong types for buffer sizes. This could result in out-of-bounds writes or other memory errors when working on large, multi-gigabyte buffers. Thanks to Felix Wilhelm for the report.
Formattable::Formattable(const Formattable* arrayToCopy, int32_t count) : UObject(), fType(kArray) { init(); fType = kArray; fValue.fArrayAndCount.fArray = createArrayCopy(arrayToCopy, count); fValue.fArrayAndCount.fCount = count; }
0
[ "CWE-190" ]
icu
53d8c8f3d181d87a6aa925b449b51c4a2c922a51
246,015,711,339,411,740,000,000,000,000,000,000,000
8
ICU-20246 Fixing another integer overflow in number parsing.
bool FromkLinuxSockAddrIn(const struct klinux_sockaddr_in *input, struct sockaddr_in *output) { if (!input || !output) { return false; } output->sin_family = AF_INET; output->sin_port = input->klinux_sin_port; InitializeToZeroSingle(&output->sin_addr); ReinterpretCopySingle(&output->sin_addr, &input->klinux_sin_port); InitializeToZeroArray(output->sin_zero); ReinterpretCopyArray( output->sin_zero, input->klinux_sin_zero, std::min(sizeof(output->sin_zero), sizeof(input->klinux_sin_zero))); return true; }
0
[ "CWE-787" ]
asylo
bda9772e7872b0d2b9bee32930cf7a4983837b39
225,534,833,427,631,600,000,000,000,000,000,000,000
15
Check input length in FromLinuxSockAddr PiperOrigin-RevId: 333785506 Change-Id: I1d68fb8954665eebc1018d80ff995cbe9e7ed6a9
int passwd_to_utf16(unsigned char *in_passwd, int length, int max_length, unsigned char *out_passwd) { #ifdef WIN32 int ret; (void)length; ret = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)in_passwd, -1, (LPWSTR)out_passwd, max_length / 2 ); if (ret == 0) return AESCRYPT_READPWD_ICONV; return ret * 2; #else #ifndef ENABLE_ICONV /* support only latin */ int i; for (i=0;i<length+1;i++) { out_passwd[i*2] = in_passwd[i]; out_passwd[i*2+1] = 0; } return length*2; #else unsigned char *ic_outbuf, *ic_inbuf; iconv_t condesc; size_t ic_inbytesleft, ic_outbytesleft; /* Max length is specified in character, but this function deals * with bytes. So, multiply by two since we are going to create a * UTF-16 string. */ max_length *= 2; ic_inbuf = in_passwd; ic_inbytesleft = length; ic_outbytesleft = max_length; ic_outbuf = out_passwd; /* Set the locale based on the current environment */ setlocale(LC_CTYPE,""); if ((condesc = iconv_open("UTF-16LE", nl_langinfo(CODESET))) == (iconv_t)(-1)) { perror("Error in iconv_open"); return -1; } if (iconv(condesc, (char ** const) &ic_inbuf, &ic_inbytesleft, (char ** const) &ic_outbuf, &ic_outbytesleft) == (size_t) -1) { switch (errno) { case E2BIG: fprintf(stderr, "Error: password too long\n"); iconv_close(condesc); return -1; break; default: /* printf("\nEILSEQ(%d), EINVAL(%d), %d\n", EILSEQ, EINVAL, errno); */ perror("Password conversion error"); iconv_close(condesc); return -1; } } iconv_close(condesc); return (max_length - ic_outbytesleft); #endif #endif }
1
[ "CWE-287", "CWE-787" ]
AESCrypt
68761851b595e96c68c3f46bfc21167e72c6a22c
276,258,250,881,594,060,000,000,000,000,000,000,000
86
Fixed security issue with passwords entered via a prompt
static void rt6_probe(struct rt6_info *rt) { struct neighbour *neigh; /* * Okay, this does not seem to be appropriate * for now, however, we need to check if it * is really so; aka Router Reachability Probing. * * Router Reachability Probe MUST be rate-limited * to no more than one per minute. */ if (!rt || !(rt->rt6i_flags & RTF_GATEWAY)) return; rcu_read_lock_bh(); neigh = __ipv6_neigh_lookup_noref(rt->dst.dev, &rt->rt6i_gateway); if (neigh) { write_lock(&neigh->lock); if (neigh->nud_state & NUD_VALID) goto out; } if (!neigh || time_after(jiffies, neigh->updated + rt->rt6i_idev->cnf.rtr_probe_interval)) { struct __rt6_probe_work *work; work = kmalloc(sizeof(*work), GFP_ATOMIC); if (neigh && work) __neigh_set_probe_once(neigh); if (neigh) write_unlock(&neigh->lock); if (work) { INIT_WORK(&work->work, rt6_probe_deferred); work->target = rt->rt6i_gateway; dev_hold(rt->dst.dev); work->dev = rt->dst.dev; schedule_work(&work->work); } } else { out: write_unlock(&neigh->lock); } rcu_read_unlock_bh(); }
0
[ "CWE-119" ]
net
c88507fbad8055297c1d1e21e599f46960cbee39
43,792,526,793,061,190,000,000,000,000,000,000,000
46
ipv6: don't set DST_NOCOUNT for remotely added routes DST_NOCOUNT should only be used if an authorized user adds routes locally. In case of routes which are added on behalf of router advertisments this flag must not get used as it allows an unlimited number of routes getting added remotely. Signed-off-by: Sabrina Dubroca <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo) { int length = 0; rdpUpdate* update = context->update; orderInfo->boundsFlags = 0; if (update_bounds_is_null(&update->currentBounds)) return 0; orderInfo->controlFlags |= ORDER_BOUNDS; if (update_bounds_equals(&update->previousBounds, &update->currentBounds)) { orderInfo->controlFlags |= ORDER_ZERO_BOUNDS_DELTAS; return 0; } else { length += 1; if (update->previousBounds.left != update->currentBounds.left) { orderInfo->bounds.left = update->currentBounds.left; orderInfo->boundsFlags |= BOUND_LEFT; length += 2; } if (update->previousBounds.top != update->currentBounds.top) { orderInfo->bounds.top = update->currentBounds.top; orderInfo->boundsFlags |= BOUND_TOP; length += 2; } if (update->previousBounds.right != update->currentBounds.right) { orderInfo->bounds.right = update->currentBounds.right; orderInfo->boundsFlags |= BOUND_RIGHT; length += 2; } if (update->previousBounds.bottom != update->currentBounds.bottom) { orderInfo->bounds.bottom = update->currentBounds.bottom; orderInfo->boundsFlags |= BOUND_BOTTOM; length += 2; } } return length; }
0
[ "CWE-119", "CWE-787" ]
FreeRDP
445a5a42c500ceb80f8fa7f2c11f3682538033f3
92,248,477,748,770,860,000,000,000,000,000,000,000
51
Fixed CVE-2018-8786 Thanks to Eyal Itkin from Check Point Software Technologies.
R_API char *r_bin_java_print_methodtype_cp_stringify(RBinJavaCPTypeObj *obj) { return r_str_newf ("%d.0x%04"PFMT64x ".%s.%d", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_method_type.descriptor_index); }
0
[ "CWE-119", "CWE-788" ]
radare2
6c4428f018d385fc80a33ecddcb37becea685dd5
328,344,555,340,856,700,000,000,000,000,000,000,000
5
Improve boundary checks to fix oobread segfaults ##crash * Reported by Cen Zhang via huntr.dev * Reproducer: bins/fuzzed/javaoob-havoc.class
CImg<T>& HSItoRGB() { if (_spectrum!=3) throw CImgInstanceException(_cimg_instance "HSItoRGB(): Instance is not a HSI image.", cimg_instance); T *p1 = data(0,0,0,0), *p2 = data(0,0,0,1), *p3 = data(0,0,0,2); const longT whd = (longT)width()*height()*depth(); cimg_pragma_openmp(parallel for cimg_openmp_if_size(whd,256)) for (longT N = 0; N<whd; ++N) { const Tfloat H = cimg::mod((Tfloat)p1[N]/60,(Tfloat)6), S = (Tfloat)p2[N], I = (Tfloat)p3[N], Z = 1 - cimg::abs(cimg::mod(H,(Tfloat)2) - 1), C = I*S/(1 + Z), X = C*Z, m = I*(1 - S)/3; Tfloat R, G, B; switch ((int)H) { case 0 : R = C; G = X; B = 0; break; case 1 : R = X; G = C; B = 0; break; case 2 : R = 0; G = C; B = X; break; case 3 : R = 0; G = X; B = C; break; case 4 : R = X; G = 0; B = C; break; default : R = C; G = 0; B = X; } p1[N] = (T)((R + m)*3*255); p2[N] = (T)((G + m)*3*255); p3[N] = (T)((B + m)*3*255); } return *this; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
81,360,289,046,605,110,000,000,000,000,000,000,000
33
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) { if (obj == Py_None) obj = NULL; if (obj) { if (PyArena_AddPyObject(arena, obj) < 0) { *out = NULL; return -1; } Py_INCREF(obj); } *out = obj; return 0; }
0
[ "CWE-125" ]
cpython
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
175,534,416,396,091,230,000,000,000,000,000,000,000
14
bpo-35766: Merge typed_ast back into CPython (GH-11645)
static void prepare_attr_stack(const char *path, int dirlen) { struct attr_stack *elem, *info; int len; char pathbuf[PATH_MAX]; /* * At the bottom of the attribute stack is the built-in * set of attribute definitions. Then, contents from * .gitattribute files from directories closer to the * root to the ones in deeper directories are pushed * to the stack. Finally, at the very top of the stack * we always keep the contents of $GIT_DIR/info/attributes. * * When checking, we use entries from near the top of the * stack, preferring $GIT_DIR/info/attributes, then * .gitattributes in deeper directories to shallower ones, * and finally use the built-in set as the default. */ if (!attr_stack) bootstrap_attr_stack(); /* * Pop the "info" one that is always at the top of the stack. */ info = attr_stack; attr_stack = info->prev; /* * Pop the ones from directories that are not the prefix of * the path we are checking. */ while (attr_stack && attr_stack->origin) { int namelen = strlen(attr_stack->origin); elem = attr_stack; if (namelen <= dirlen && !strncmp(elem->origin, path, namelen)) break; debug_pop(elem); attr_stack = elem->prev; free_attr_elem(elem); } /* * Read from parent directories and push them down */ if (!is_bare_repository()) { while (1) { char *cp; len = strlen(attr_stack->origin); if (dirlen <= len) break; memcpy(pathbuf, path, dirlen); memcpy(pathbuf + dirlen, "/", 2); cp = strchr(pathbuf + len + 1, '/'); strcpy(cp + 1, GITATTRIBUTES_FILE); elem = read_attr(pathbuf, 0); *cp = '\0'; elem->origin = strdup(pathbuf); elem->prev = attr_stack; attr_stack = elem; debug_push(elem); } } /* * Finally push the "info" one at the top of the stack. */ info->prev = attr_stack; attr_stack = info; }
1
[]
git
f66cf96d7c613a8129436a5d76ef7b74ee302436
252,101,527,543,494,450,000,000,000,000,000,000,000
74
Fix buffer overflow in prepare_attr_stack If PATH_MAX on your system is smaller than a path stored in the git repo, it may cause the buffer overflow in prepare_attr_stack. Signed-off-by: Dmitry Potapov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
LIBOPENMPT_MODPLUG_API unsigned int ModPlug_GetMasterVolume(ModPlugFile* file) { int32_t val; if(!file) return 0; val = 0; if(!openmpt_module_get_render_param(file->mod,OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL,&val)) return 128; return (unsigned int)(128.0*pow(10.0,val*0.0005)); }
0
[ "CWE-120", "CWE-295" ]
openmpt
927688ddab43c2b203569de79407a899e734fabe
211,463,475,450,066,100,000,000,000,000,000,000,000
8
[Fix] libmodplug: C API: Limit the length of strings copied to the output buffer of ModPlug_InstrumentName() and ModPlug_SampleName() to 32 bytes (including terminating null) as is done by original libmodplug. This avoids potential buffer overflows in software relying on this limit instead of querying the required buffer size beforehand. libopenmpt can return strings longer than 32 bytes here beacuse the internal limit of 32 bytes applies to strings encoded in arbitrary character encodings but the API returns them converted to UTF-8, which can be longer. (reported by Antonio Morales Maldonado of Semmle Security Research Team) git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@12127 56274372-70c3-4bfc-bfc3-4c3a0b034d27
static bool init_downstream_request(JSContext *cx, HandleObject request) { MOZ_ASSERT(Request::request_handle(request).handle == INVALID_HANDLE); RequestHandle request_handle = {INVALID_HANDLE}; BodyHandle body_handle = {INVALID_HANDLE}; if (!HANDLE_RESULT(cx, xqd_req_body_downstream_get(&request_handle, &body_handle))) return false; JS::SetReservedSlot(request, Request::Slots::Request, JS::Int32Value(request_handle.handle)); JS::SetReservedSlot(request, Request::Slots::Body, JS::Int32Value(body_handle.handle)); // Set the method. OwnedHostCallBuffer buffer; size_t num_written = 0; if (!HANDLE_RESULT(cx, xqd_req_method_get(request_handle, buffer.get(), HOSTCALL_BUFFER_LEN, &num_written))) { return false; } bool is_get = strncmp(buffer.get(), "GET", num_written) == 0; if (!is_get) { RootedString method(cx, JS_NewStringCopyN(cx, buffer.get(), num_written)); if (!method) { return false; } JS::SetReservedSlot(request, Request::Slots::Method, JS::StringValue(method)); } // Set whether we have a body depending on the method. // TODO: verify if that's right. I.e. whether we should treat all requests // that are not GET or HEAD as having a body, which might just be 0-length. // It's not entirely clear what else we even could do here though. if (!(is_get || strncmp(buffer.get(), "HEAD", num_written) == 0)) { JS::SetReservedSlot(request, Request::Slots::HasBody, JS::TrueValue()); } size_t bytes_read; UniqueChars buf( read_from_handle_all<xqd_req_uri_get, RequestHandle>(cx, request_handle, &bytes_read, false)); if (!buf) return false; RootedString url(cx, JS_NewStringCopyN(cx, buf.get(), bytes_read)); if (!url) return false; JS::SetReservedSlot(request, Request::Slots::URL, JS::StringValue(url)); // Set the URL for `globalThis.location` to the client request's URL. RootedObject url_instance(cx, JS_NewObjectWithGivenProto(cx, &URL::class_, URL::proto_obj)); if (!url_instance) return false; SpecString spec((uint8_t *)buf.release(), bytes_read, bytes_read); builtins::WorkerLocation::url = URL::create(cx, url_instance, spec); if (!builtins::WorkerLocation::url) { return false; } // Set `fastly.baseURL` to the origin of the client request's URL. // Note that this only happens if baseURL hasn't already been set to another // value explicitly. if (!builtins::Fastly::baseURL.get()) { RootedObject url_instance(cx, JS_NewObjectWithGivenProto(cx, &URL::class_, URL::proto_obj)); if (!url_instance) return false; builtins::Fastly::baseURL = URL::create(cx, url_instance, URL::origin(cx, builtins::WorkerLocation::url)); if (!builtins::Fastly::baseURL) return false; } return true; }
0
[ "CWE-94" ]
js-compute-runtime
65524ffc962644e9fc39f4b368a326b6253912a9
46,796,677,223,352,720,000,000,000,000,000,000,000
75
use rangom_get instead of arc4random as arc4random does not work correctly with wizer wizer causes the seed in arc4random to be the same between executions which is not random
static bool stacksafe(struct bpf_func_state *old, struct bpf_func_state *cur, struct idpair *idmap) { int i, spi; /* if explored stack has more populated slots than current stack * such stacks are not equivalent */ if (old->allocated_stack > cur->allocated_stack) return false; /* walk slots of the explored stack and ignore any additional * slots in the current stack, since explored(safe) state * didn't use them */ for (i = 0; i < old->allocated_stack; i++) { spi = i / BPF_REG_SIZE; if (!(old->stack[spi].spilled_ptr.live & REG_LIVE_READ)) /* explored state didn't use this */ continue; if (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_INVALID) continue; /* if old state was safe with misc data in the stack * it will be safe with zero-initialized stack. * The opposite is not true */ if (old->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_MISC && cur->stack[spi].slot_type[i % BPF_REG_SIZE] == STACK_ZERO) continue; if (old->stack[spi].slot_type[i % BPF_REG_SIZE] != cur->stack[spi].slot_type[i % BPF_REG_SIZE]) /* Ex: old explored (safe) state has STACK_SPILL in * this stack slot, but current has has STACK_MISC -> * this verifier states are not equivalent, * return false to continue verification of this path */ return false; if (i % BPF_REG_SIZE) continue; if (old->stack[spi].slot_type[0] != STACK_SPILL) continue; if (!regsafe(&old->stack[spi].spilled_ptr, &cur->stack[spi].spilled_ptr, idmap)) /* when explored and current stack slot are both storing * spilled registers, check that stored pointers types * are the same as well. * Ex: explored safe path could have stored * (bpf_reg_state) {.type = PTR_TO_STACK, .off = -8} * but current path has stored: * (bpf_reg_state) {.type = PTR_TO_STACK, .off = -16} * such verifier states are not equivalent. * return false to continue verification of this path */ return false; } return true; }
0
[ "CWE-125" ]
linux
b799207e1e1816b09e7a5920fbb2d5fcf6edd681
91,541,033,809,659,000,000,000,000,000,000,000,000
61
bpf: 32-bit RSH verification must truncate input before the ALU op When I wrote commit 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification"), I assumed that, in order to emulate 64-bit arithmetic with 32-bit logic, it is sufficient to just truncate the output to 32 bits; and so I just moved the register size coercion that used to be at the start of the function to the end of the function. That assumption is true for almost every op, but not for 32-bit right shifts, because those can propagate information towards the least significant bit. Fix it by always truncating inputs for 32-bit ops to 32 bits. Also get rid of the coerce_reg_to_size() after the ALU op, since that has no effect. Fixes: 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification") Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
set_errorlist( win_T *wp, list_T *list, int action, char_u *title, dict_T *what) { qf_info_T *qi = &ql_info; int retval = OK; if (wp != NULL) { qi = ll_get_or_alloc_list(wp); if (qi == NULL) return FAIL; } if (action == 'f') { // Free the entire quickfix or location list stack qf_free_stack(wp, qi); return OK; } // A dict argument cannot be specified with a non-empty list argument if (list->lv_len != 0 && what != NULL) { semsg(_(e_invalid_argument_str), _("cannot have both a list and a \"what\" argument")); return FAIL; } incr_quickfix_busy(); if (what != NULL) retval = qf_set_properties(qi, what, action, title); else { retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); if (retval == OK) qf_list_changed(qf_get_curlist(qi)); } decr_quickfix_busy(); return retval; }
0
[ "CWE-416" ]
vim
4f1b083be43f351bc107541e7b0c9655a5d2c0bb
264,434,930,699,348,820,000,000,000,000,000,000,000
47
patch 9.0.0322: crash when no errors and 'quickfixtextfunc' is set Problem: Crash when no errors and 'quickfixtextfunc' is set. Solution: Do not handle errors if there aren't any.
mrb_mod_module_function(mrb_state *mrb, mrb_value mod) { const mrb_value *argv; mrb_int argc, i; mrb_sym mid; mrb_method_t m; struct RClass *rclass; int ai; mrb_check_type(mrb, mod, MRB_TT_MODULE); mrb_get_args(mrb, "*", &argv, &argc); if (argc == 0) { /* set MODFUNC SCOPE if implemented */ return mod; } /* set PRIVATE method visibility if implemented */ /* mrb_mod_dummy_visibility(mrb, mod); */ for (i=0; i<argc; i++) { mrb_check_type(mrb, argv[i], MRB_TT_SYMBOL); mid = mrb_symbol(argv[i]); rclass = mrb_class_ptr(mod); m = mrb_method_search(mrb, rclass, mid); prepare_singleton_class(mrb, (struct RBasic*)rclass); ai = mrb_gc_arena_save(mrb); mrb_define_method_raw(mrb, rclass->c, mid, m); mrb_gc_arena_restore(mrb, ai); } return mod; }
0
[ "CWE-787" ]
mruby
b1d0296a937fe278239bdfac840a3fd0e93b3ee9
144,371,510,452,531,630,000,000,000,000,000,000,000
35
class.c: clear method cache after `remove_method`.
void perf_event_namespaces(struct task_struct *task) { struct perf_namespaces_event namespaces_event; struct perf_ns_link_info *ns_link_info; if (!atomic_read(&nr_namespaces_events)) return; namespaces_event = (struct perf_namespaces_event){ .task = task, .event_id = { .header = { .type = PERF_RECORD_NAMESPACES, .misc = 0, .size = sizeof(namespaces_event.event_id), }, /* .pid */ /* .tid */ .nr_namespaces = NR_NAMESPACES, /* .link_info[NR_NAMESPACES] */ }, }; ns_link_info = namespaces_event.event_id.link_info; perf_fill_ns_link_info(&ns_link_info[MNT_NS_INDEX], task, &mntns_operations); #ifdef CONFIG_USER_NS perf_fill_ns_link_info(&ns_link_info[USER_NS_INDEX], task, &userns_operations); #endif #ifdef CONFIG_NET_NS perf_fill_ns_link_info(&ns_link_info[NET_NS_INDEX], task, &netns_operations); #endif #ifdef CONFIG_UTS_NS perf_fill_ns_link_info(&ns_link_info[UTS_NS_INDEX], task, &utsns_operations); #endif #ifdef CONFIG_IPC_NS perf_fill_ns_link_info(&ns_link_info[IPC_NS_INDEX], task, &ipcns_operations); #endif #ifdef CONFIG_PID_NS perf_fill_ns_link_info(&ns_link_info[PID_NS_INDEX], task, &pidns_operations); #endif #ifdef CONFIG_CGROUPS perf_fill_ns_link_info(&ns_link_info[CGROUP_NS_INDEX], task, &cgroupns_operations); #endif perf_iterate_sb(perf_event_namespaces_output, &namespaces_event, NULL); }
0
[ "CWE-401" ]
tip
7bdb157cdebbf95a1cd94ed2e01b338714075d00
61,775,625,605,954,550,000,000,000,000,000,000,000
57
perf/core: Fix a memory leak in perf_event_parse_addr_filter() As shown through runtime testing, the "filename" allocation is not always freed in perf_event_parse_addr_filter(). There are three possible ways that this could happen: - It could be allocated twice on subsequent iterations through the loop, - or leaked on the success path, - or on the failure path. Clean up the code flow to make it obvious that 'filename' is always freed in the reallocation path and in the two return paths as well. We rely on the fact that kfree(NULL) is NOP and filename is initialized with NULL. This fixes the leak. No other side effects expected. [ Dan Carpenter: cleaned up the code flow & added a changelog. ] [ Ingo Molnar: updated the changelog some more. ] Fixes: 375637bc5249 ("perf/core: Introduce address range filtering") Signed-off-by: "kiyin(尹亮)" <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: "Srivatsa S. Bhat" <[email protected]> Cc: Anthony Liguori <[email protected]> -- kernel/events/core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
static int kvaser_usb_leaf_wait_cmd(const struct kvaser_usb *dev, u8 id, struct kvaser_cmd *cmd) { struct kvaser_cmd *tmp; void *buf; int actual_len; int err; int pos; unsigned long to = jiffies + msecs_to_jiffies(KVASER_USB_TIMEOUT); buf = kzalloc(KVASER_USB_RX_BUFFER_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; do { err = kvaser_usb_recv_cmd(dev, buf, KVASER_USB_RX_BUFFER_SIZE, &actual_len); if (err < 0) goto end; pos = 0; while (pos <= actual_len - CMD_HEADER_LEN) { tmp = buf + pos; /* Handle commands crossing the USB endpoint max packet * size boundary. Check kvaser_usb_read_bulk_callback() * for further details. */ if (tmp->len == 0) { pos = round_up(pos, le16_to_cpu (dev->bulk_in->wMaxPacketSize)); continue; } if (pos + tmp->len > actual_len) { dev_err_ratelimited(&dev->intf->dev, "Format error\n"); break; } if (tmp->id == id) { memcpy(cmd, tmp, tmp->len); goto end; } pos += tmp->len; } } while (time_before(jiffies, to)); err = -EINVAL; end: kfree(buf); return err; }
0
[ "CWE-200", "CWE-908" ]
linux
da2311a6385c3b499da2ed5d9be59ce331fa93e9
228,151,646,689,958,230,000,000,000,000,000,000,000
57
can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices Uninitialized Kernel memory can leak to USB devices. Fix this by using kzalloc() instead of kmalloc(). Signed-off-by: Xiaolong Huang <[email protected]> Fixes: 7259124eac7d ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c") Cc: linux-stable <[email protected]> # >= v4.19 Signed-off-by: Marc Kleine-Budde <[email protected]>
static MagickBooleanType TIFFGetProfiles(TIFF *tiff,Image *image, ExceptionInfo *exception) { MagickBooleanType status; uint32 length = 0; unsigned char *profile = (unsigned char *) NULL; status=MagickTrue; #if defined(TIFFTAG_ICCPROFILE) if ((TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) status=ReadProfile(image,"icc",profile,(ssize_t) length,exception); #endif #if defined(TIFFTAG_PHOTOSHOP) if ((TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) status=ReadProfile(image,"8bim",profile,(ssize_t) length,exception); #endif #if defined(TIFFTAG_RICHTIFFIPTC) if ((TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) { const TIFFField *field; if (TIFFIsByteSwapped(tiff) != 0) TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length); field=TIFFFieldWithTag(tiff,TIFFTAG_RICHTIFFIPTC); if (TIFFFieldDataType(field) == TIFF_LONG) status=ReadProfile(image,"iptc",profile,4L*length,exception); else status=ReadProfile(image,"iptc",profile,length,exception); } #endif #if defined(TIFFTAG_XMLPACKET) if ((TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) { StringInfo *dng; status=ReadProfile(image,"xmp",profile,(ssize_t) length,exception); dng=BlobToStringInfo(profile,length); if (dng != (StringInfo *) NULL) { const char *target = "dc:format=\"image/dng\""; if (strstr((char *) GetStringInfoDatum(dng),target) != (char *) NULL) (void) CopyMagickString(image->magick,"DNG",MagickPathExtent); dng=DestroyStringInfo(dng); } } #endif if ((TIFFGetField(tiff,34118,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) status=ReadProfile(image,"tiff:34118",profile,(ssize_t) length, exception); if ((TIFFGetField(tiff,37724,&length,&profile) == 1) && (profile != (unsigned char *) NULL)) status=ReadProfile(image,"tiff:37724",profile,(ssize_t) length,exception); return(status); }
0
[ "CWE-125" ]
ImageMagick
824f344ceb823e156ad6e85314d79c087933c2a0
13,944,005,594,410,488,000,000,000,000,000,000,000
68
Check the type of the field before performing the multiplication (details in #2132)
static av_always_inline void color_cache_put(ImageContext *img, uint32_t c) { uint32_t cache_idx = (0x1E35A7BD * c) >> (32 - img->color_cache_bits); img->color_cache[cache_idx] = c; }
0
[ "CWE-119", "CWE-787" ]
FFmpeg
6b5d3fb26fb4be48e4966e4b1d97c2165538d4ef
33,643,511,663,342,993,000,000,000,000,000,000,000
5
avcodec/webp: Always set pix_fmt Fixes: out of array access Fixes: 1434/clusterfuzz-testcase-minimized-6314998085189632 Fixes: 1435/clusterfuzz-testcase-minimized-6483783723253760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Reviewed-by: "Ronald S. Bultje" <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
ClientRequestContext::clientAccessCheckDone(const Acl::Answer &answer) { acl_checklist = NULL; err_type page_id; Http::StatusCode status; debugs(85, 2, "The request " << http->request->method << ' ' << http->uri << " is " << answer << "; last ACL checked: " << (AclMatchedName ? AclMatchedName : "[none]")); #if USE_AUTH char const *proxy_auth_msg = "<null>"; if (http->getConn() != NULL && http->getConn()->getAuth() != NULL) proxy_auth_msg = http->getConn()->getAuth()->denyMessage("<null>"); else if (http->request->auth_user_request != NULL) proxy_auth_msg = http->request->auth_user_request->denyMessage("<null>"); #endif if (!answer.allowed()) { // auth has a grace period where credentials can be expired but okay not to challenge. /* Send an auth challenge or error */ // XXX: do we still need aclIsProxyAuth() ? bool auth_challenge = (answer == ACCESS_AUTH_REQUIRED || aclIsProxyAuth(AclMatchedName)); debugs(85, 5, "Access Denied: " << http->uri); debugs(85, 5, "AclMatchedName = " << (AclMatchedName ? AclMatchedName : "<null>")); #if USE_AUTH if (auth_challenge) debugs(33, 5, "Proxy Auth Message = " << (proxy_auth_msg ? proxy_auth_msg : "<null>")); #endif /* * NOTE: get page_id here, based on AclMatchedName because if * USE_DELAY_POOLS is enabled, then AclMatchedName gets clobbered in * the clientCreateStoreEntry() call just below. Pedro Ribeiro * <[email protected]> */ page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName, answer != ACCESS_AUTH_REQUIRED); http->logType.update(LOG_TCP_DENIED); if (auth_challenge) { #if USE_AUTH if (http->request->flags.sslBumped) { /*SSL Bumped request, authentication is not possible*/ status = Http::scForbidden; } else if (!http->flags.accel) { /* Proxy authorisation needed */ status = Http::scProxyAuthenticationRequired; } else { /* WWW authorisation needed */ status = Http::scUnauthorized; } #else // need auth, but not possible to do. status = Http::scForbidden; #endif if (page_id == ERR_NONE) page_id = ERR_CACHE_ACCESS_DENIED; } else { status = Http::scForbidden; if (page_id == ERR_NONE) page_id = ERR_ACCESS_DENIED; } Ip::Address tmpnoaddr; tmpnoaddr.setNoAddr(); error = clientBuildError(page_id, status, NULL, http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmpnoaddr, http->request, http->al ); #if USE_AUTH error->auth_user_request = http->getConn() != NULL && http->getConn()->getAuth() != NULL ? http->getConn()->getAuth() : http->request->auth_user_request; #endif readNextRequest = true; } /* ACCESS_ALLOWED continues here ... */ xfree(http->uri); http->uri = SBufToCstring(http->request->effectiveRequestUri()); http->doCallouts(); }
0
[ "CWE-116" ]
squid
6bf66733c122804fada7f5839ef5f3b57e57591c
111,501,485,003,781,870,000,000,000,000,000,000,000
87
Handle more Range requests (#790) Also removed some effectively unused code.
bool HierarchicalBitmapRequester::isNextMCULineReady(void) const { #if ACCUSOFT_CODE // MCUs can only be written if the smallest scale, which is written first, // is ready. return m_pSmallestScale->isNextMCULineReady(); #else return false; #endif }
0
[ "CWE-125", "CWE-787" ]
libjpeg
187035b9726710b4fe11d565c7808975c930895d
84,748,956,304,599,710,000,000,000,000,000,000,000
10
The code now checks for consistency of the MCU sizes across hierarchical levels, and fails in case they are different.
ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location) { ssh_scp scp = NULL; if (session == NULL) { goto error; } scp = (ssh_scp)calloc(1, sizeof(struct ssh_scp_struct)); if (scp == NULL) { ssh_set_error(session, SSH_FATAL, "Error allocating memory for ssh_scp"); goto error; } if ((mode & ~SSH_SCP_RECURSIVE) != SSH_SCP_WRITE && (mode & ~SSH_SCP_RECURSIVE) != SSH_SCP_READ) { ssh_set_error(session, SSH_FATAL, "Invalid mode %d for ssh_scp_new()", mode); goto error; } scp->location = strdup(location); if (scp->location == NULL) { ssh_set_error(session, SSH_FATAL, "Error allocating memory for ssh_scp"); goto error; } scp->session = session; scp->mode = mode & ~SSH_SCP_RECURSIVE; scp->recursive = (mode & SSH_SCP_RECURSIVE) != 0; scp->channel = NULL; scp->state = SSH_SCP_NEW; return scp; error: ssh_scp_free(scp); return NULL; }
1
[]
libssh
391c78de9d0f7baec3a44d86a76f4e1324eb9529
286,533,071,759,234,870,000,000,000,000,000,000,000
42
CVE-2019-14889: scp: Don't allow file path longer than 32kb Signed-off-by: Andreas Schneider <[email protected]> Reviewed-by: Jakub Jelen <[email protected]> (cherry picked from commit 0b5ee397260b6e08dffa2c1ce515a153aaeda765)
void RGWSetRequestPayment_ObjStore_S3::send_response() { if (op_ret) set_req_state_err(s, op_ret); dump_errno(s); end_header(s); }
0
[ "CWE-79" ]
ceph
8f90658c731499722d5f4393c8ad70b971d05f77
317,769,928,548,221,560,000,000,000,000,000,000,000
7
rgw: reject unauthenticated response-header actions Signed-off-by: Matt Benjamin <[email protected]> Reviewed-by: Casey Bodley <[email protected]> (cherry picked from commit d8dd5e513c0c62bbd7d3044d7e2eddcd897bd400)
void onComplete(const Status& status, ContextImpl& context) const override { auto& completion_state = context.getCompletionState(this); if (completion_state.is_completed_) { return; } if (++completion_state.number_completed_children_ == verifiers_.size() || Status::Ok != status) { completion_state.is_completed_ = true; completeWithStatus(status, context); } }
0
[ "CWE-303", "CWE-703" ]
envoy
ea39e3cba652bcc4b11bb0d5c62b017e584d2e5a
242,576,646,306,226,560,000,000,000,000,000,000,000
11
jwt_authn: fix a bug where JWT with wrong issuer is allowed in allow_missing case (#15194) [jwt] When allow_missing is used inside RequiresAny, the requests with JWT with wrong issuer are accepted. This is a bug, allow_missing should only allow requests without any JWT. This change fixed the above issue by preserving JwtUnknownIssuer in allow_missing case. Signed-off-by: Wayne Zhang <[email protected]>
GetStatusInfo(struct upnphttp * h, const char * action, const char * ns) { static const char resp[] = "<u:%sResponse " "xmlns:u=\"%s\">" "<NewConnectionStatus>%s</NewConnectionStatus>" "<NewLastConnectionError>ERROR_NONE</NewLastConnectionError>" "<NewUptime>%ld</NewUptime>" "</u:%sResponse>"; char body[512]; int bodylen; time_t uptime; const char * status; /* ConnectionStatus possible values : * Unconfigured, Connecting, Connected, PendingDisconnect, * Disconnecting, Disconnected */ status = get_wan_connection_status_str(ext_if_name); uptime = upnp_get_uptime(); bodylen = snprintf(body, sizeof(body), resp, action, ns, /*SERVICE_TYPE_WANIPC,*/ status, (long)uptime, action); BuildSendAndCloseSoapResp(h, body, bodylen); }
0
[ "CWE-476" ]
miniupnp
13585f15c7f7dc28bbbba1661efb280d530d114c
38,082,673,897,806,710,000,000,000,000,000,000,000
25
GetOutboundPinholeTimeout: check args
static int first_nibble_is_4(RAnal* anal, RAnalOp* op, ut16 code){ switch (code & 0xF0FF) { //todo: implement case 0x4020: //shal op->type = R_ANAL_OP_TYPE_SAL; break; case 0x4021: //shar op->type = R_ANAL_OP_TYPE_SAR; break; case 0x4000: //shll case 0x4008: //shll2 case 0x4018: //shll8 case 0x4028: //shll16 op->type = R_ANAL_OP_TYPE_SHL; break; case 0x4001: //shlr case 0x4009: //shlr2 case 0x4019: //shlr8 case 0x4029: //shlr16 op->type = R_ANAL_OP_TYPE_SHR; break; default: break; } if (IS_JSR(code)) { op->type = R_ANAL_OP_TYPE_UCALL; //call to reg op->delay = 1; op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG(code)); } else if ( IS_JMP(code) ) { op->type = R_ANAL_OP_TYPE_UJMP; //jmp to reg op->dst = anal_fill_ai_rg (anal, GET_TARGET_REG(code)); op->delay = 1; op->eob = true; } else if (IS_CMPPL(code) || IS_CMPPZ(code)) { op->type = R_ANAL_OP_TYPE_CMP; //todo: implement } else if (IS_LDCLSR1(code) || IS_LDSLMAC(code) || IS_LDSLPR(code)) { op->type = R_ANAL_OP_TYPE_POP; //todo: implement } else if (IS_LDCSR1(code) || IS_LDSMAC(code) || IS_LDSPR(code)) { op->type = R_ANAL_OP_TYPE_MOV; //todo: implement } else if (IS_ROT(code)) { op->type = (code&1)? R_ANAL_OP_TYPE_ROR:R_ANAL_OP_TYPE_ROL; //todo: implement rot* vs rotc* } else if (IS_STCLSR1(code) || IS_STSLMAC(code) || IS_STSLPR(code)) { op->type = R_ANAL_OP_TYPE_PUSH; //todo: implement st*.l *,@-Rn } else if (IS_TASB(code)) { op->type = R_ANAL_OP_TYPE_UNK; //todo: implement } else if (IS_DT(code)) { op->type = R_ANAL_OP_TYPE_UNK; //todo: implement } return op->size; }
0
[ "CWE-125" ]
radare2
77c47cf873dd55b396da60baa2ca83bbd39e4add
243,470,601,441,424,900,000,000,000,000,000,000,000
58
Fix #9903 - oobread in RAnal.sh
static int cpia2_g_jpegcomp(struct file *file, void *fh, struct v4l2_jpegcompression *parms) { struct camera_data *cam = video_drvdata(file); memset(parms, 0, sizeof(*parms)); parms->quality = 80; // TODO: Can this be made meaningful? parms->jpeg_markers = V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI; if(!cam->params.compression.inhibit_htables) { parms->jpeg_markers |= V4L2_JPEG_MARKER_DHT; } parms->APPn = cam->APPn; parms->APP_len = cam->APP_len; if(cam->APP_len > 0) { memcpy(parms->APP_data, cam->APP_data, cam->APP_len); parms->jpeg_markers |= V4L2_JPEG_MARKER_APP; } parms->COM_len = cam->COM_len; if(cam->COM_len > 0) { memcpy(parms->COM_data, cam->COM_data, cam->COM_len); parms->jpeg_markers |= JPEG_MARKER_COM; } DBG("G_JPEGCOMP APP_len:%d COM_len:%d\n", parms->APP_len, parms->COM_len); return 0; }
0
[ "CWE-416" ]
linux
dea37a97265588da604c6ba80160a287b72c7bfd
267,745,555,056,054,620,000,000,000,000,000,000,000
31
media: cpia2: Fix use-after-free in cpia2_exit Syzkaller report this: BUG: KASAN: use-after-free in sysfs_remove_file_ns+0x5f/0x70 fs/sysfs/file.c:468 Read of size 8 at addr ffff8881f59a6b70 by task syz-executor.0/8363 CPU: 0 PID: 8363 Comm: syz-executor.0 Not tainted 5.0.0-rc8+ #3 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xfa/0x1ce lib/dump_stack.c:113 print_address_description+0x65/0x270 mm/kasan/report.c:187 kasan_report+0x149/0x18d mm/kasan/report.c:317 sysfs_remove_file_ns+0x5f/0x70 fs/sysfs/file.c:468 sysfs_remove_file include/linux/sysfs.h:519 [inline] driver_remove_file+0x40/0x50 drivers/base/driver.c:122 usb_remove_newid_files drivers/usb/core/driver.c:212 [inline] usb_deregister+0x12a/0x3b0 drivers/usb/core/driver.c:1005 cpia2_exit+0xa/0x16 [cpia2] __do_sys_delete_module kernel/module.c:1018 [inline] __se_sys_delete_module kernel/module.c:961 [inline] __x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f86f3754c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000300 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f86f37556bc R13: 00000000004bcca9 R14: 00000000006f6b48 R15: 00000000ffffffff Allocated by task 8363: set_track mm/kasan/common.c:85 [inline] __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:495 kmalloc include/linux/slab.h:545 [inline] kzalloc include/linux/slab.h:740 [inline] bus_add_driver+0xc0/0x610 drivers/base/bus.c:651 driver_register+0x1bb/0x3f0 drivers/base/driver.c:170 usb_register_driver+0x267/0x520 drivers/usb/core/driver.c:965 0xffffffffc1b4817c do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 8363: set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:457 slab_free_hook mm/slub.c:1430 [inline] slab_free_freelist_hook mm/slub.c:1457 [inline] slab_free mm/slub.c:3005 [inline] kfree+0xe1/0x270 mm/slub.c:3957 kobject_cleanup lib/kobject.c:662 [inline] kobject_release lib/kobject.c:691 [inline] kref_put include/linux/kref.h:67 [inline] kobject_put+0x146/0x240 lib/kobject.c:708 bus_remove_driver+0x10e/0x220 drivers/base/bus.c:732 driver_unregister+0x6c/0xa0 drivers/base/driver.c:197 usb_register_driver+0x341/0x520 drivers/usb/core/driver.c:980 0xffffffffc1b4817c do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8881f59a6b40 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 48 bytes inside of 256-byte region [ffff8881f59a6b40, ffff8881f59a6c40) The buggy address belongs to the page: page:ffffea0007d66980 count:1 mapcount:0 mapping:ffff8881f6c02e00 index:0x0 flags: 0x2fffc0000000200(slab) raw: 02fffc0000000200 dead000000000100 dead000000000200 ffff8881f6c02e00 raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881f59a6a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8881f59a6a80: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc >ffff8881f59a6b00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ^ ffff8881f59a6b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881f59a6c00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc cpia2_init does not check return value of cpia2_init, if it failed in usb_register_driver, there is already cleanup using driver_unregister. No need call cpia2_usb_cleanup on module exit. Reported-by: Hulk Robot <[email protected]> Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>