func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
getHostName() { long hostNameMax = HOST_NAME_MAX; if (hostNameMax < 255) { // https://bugzilla.redhat.com/show_bug.cgi?id=130733 hostNameMax = 255; } string buf(hostNameMax + 1, '\0'); if (gethostname(&buf[0], hostNameMax + 1) == 0) { buf[hostNameMax] = '\0'; return string(buf.c_str()); } else { int e = errno; throw SystemException("Unable to query the system's host name", e); } }
0
[ "CWE-401" ]
passenger
94428057c602da3d6d34ef75c78091066ecac5c0
90,154,894,220,727,450,000,000,000,000,000,000,000
16
Fix a symlink-related security vulnerability. The fix in commit 34b10878 and contained a small attack time window in between two filesystem operations. This has been fixed.
static void test_strnspn(void) { size_t len; len = c_shquote_strnspn(NULL, 0, "a"); c_assert(len == 0); len = c_shquote_strnspn("a", 1, ""); c_assert(len == 0); len = c_shquote_strnspn("ab", 2, "ac"); c_assert(len == 1); len = c_shquote_strnspn("ab", 2, "bc"); c_assert(len == 0); len = c_shquote_strnspn("ab", 2, "\xff"); c_assert(len == 0); }
0
[ "CWE-787" ]
c-shquote
7fd15f8e272136955f7ffc37df29fbca9ddceca1
90,550,077,861,772,900,000,000,000,000,000,000,000
18
strnspn: fix buffer overflow Fix the strnspn and strncspn functions to use a properly sized buffer. It used to be 1 byte too short. Checking for `0xff` in a string will thus write `0xff` once byte beyond the stack space of the local buffer. Note that the public API does not allow to pass `0xff` to those functions. Therefore, this is a read-only buffer overrun, possibly causing bogus reports from the parser, but still well-defined. Reported-by: Steffen Robertz Signed-off-by: David Rheinsberg <[email protected]>
static my_bool cli_read_query_result(MYSQL *mysql) { uchar *pos; ulong field_count; MYSQL_DATA *fields; ulong length; DBUG_ENTER("cli_read_query_result"); if ((length = cli_safe_read(mysql)) == packet_error) DBUG_RETURN(1); free_old_query(mysql); /* Free old result */ #ifdef MYSQL_CLIENT /* Avoid warn of unused labels*/ get_info: #endif pos=(uchar*) mysql->net.read_pos; if ((field_count= net_field_length(&pos)) == 0) { mysql->affected_rows= net_field_length_ll(&pos); mysql->insert_id= net_field_length_ll(&pos); DBUG_PRINT("info",("affected_rows: %lu insert_id: %lu", (ulong) mysql->affected_rows, (ulong) mysql->insert_id)); if (protocol_41(mysql)) { mysql->server_status=uint2korr(pos); pos+=2; mysql->warning_count=uint2korr(pos); pos+=2; } else if (mysql->server_capabilities & CLIENT_TRANSACTIONS) { /* MySQL 4.0 protocol */ mysql->server_status=uint2korr(pos); pos+=2; mysql->warning_count= 0; } DBUG_PRINT("info",("status: %u warning_count: %u", mysql->server_status, mysql->warning_count)); if (pos < mysql->net.read_pos+length && net_field_length(&pos)) mysql->info=(char*) pos; #if defined(CLIENT_PROTOCOL_TRACING) if (mysql->server_status & SERVER_MORE_RESULTS_EXISTS) MYSQL_TRACE_STAGE(mysql, WAIT_FOR_RESULT); else MYSQL_TRACE_STAGE(mysql, READY_FOR_COMMAND); #endif DBUG_RETURN(0); } #ifdef MYSQL_CLIENT if (field_count == NULL_LENGTH) /* LOAD DATA LOCAL INFILE */ { int error; MYSQL_TRACE_STAGE(mysql, FILE_REQUEST); if (!(mysql->options.client_flag & CLIENT_LOCAL_FILES)) { set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); DBUG_RETURN(1); } error= handle_local_infile(mysql,(char*) pos); MYSQL_TRACE_STAGE(mysql, WAIT_FOR_RESULT); if ((length= cli_safe_read(mysql)) == packet_error || error) DBUG_RETURN(1); goto get_info; /* Get info packet */ } #endif if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) mysql->server_status|= SERVER_STATUS_IN_TRANS; MYSQL_TRACE_STAGE(mysql, WAIT_FOR_FIELD_DEF); if (!(fields=cli_read_rows(mysql,(MYSQL_FIELD*)0, protocol_41(mysql) ? 7:5))) DBUG_RETURN(1); if (!(mysql->fields=unpack_fields(mysql, fields,&mysql->field_alloc, (uint) field_count,0, mysql->server_capabilities))) DBUG_RETURN(1); mysql->status= MYSQL_STATUS_GET_RESULT; mysql->field_count= (uint) field_count; MYSQL_TRACE_STAGE(mysql, WAIT_FOR_ROW); DBUG_PRINT("exit",("ok")); DBUG_RETURN(0);
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
146,789,640,634,701,080,000,000,000,000,000,000,000
86
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
void TfLiteQuantizationFree(TfLiteQuantization* quantization) { if (quantization->type == kTfLiteAffineQuantization) { TfLiteAffineQuantization* q_params = (TfLiteAffineQuantization*)(quantization->params); if (q_params->scale) { TfLiteFloatArrayFree(q_params->scale); q_params->scale = NULL; } if (q_params->zero_point) { TfLiteIntArrayFree(q_params->zero_point); q_params->zero_point = NULL; } free(q_params); } quantization->params = NULL; quantization->type = kTfLiteNoQuantization; }
0
[ "CWE-190" ]
tensorflow
7c8cc4ec69cd348e44ad6a2699057ca88faad3e5
45,627,662,156,129,850,000,000,000,000,000,000,000
17
Fix a dangerous integer overflow and a malloc of negative size. PiperOrigin-RevId: 371254154 Change-Id: I250a98a3df26328770167025670235a963a72da0
SWFShape_setLineStyle2filled_internal(SWFShape shape, unsigned short width, SWFFillStyle fill, int flags, float miterLimit) { int line; if ( shape->isEnded ) return; for ( line=0; line<shape->nLines; ++line ) { if ( SWFLineStyle_equals2filled(shape->lines[line], width, fill, flags) ) break; } if ( line == shape->nLines ) line = SWFShape_addLineStyle2filled(shape, width, fill, flags, miterLimit); else ++line; finishSetLine(shape, line, width); }
0
[ "CWE-20", "CWE-476" ]
libming
6e76e8c71cb51c8ba0aa9737a636b9ac3029887f
215,221,846,462,820,100,000,000,000,000,000,000,000
22
SWFShape_setLeftFillStyle: prevent fill overflow
void xpendingCommand(client *c) { int justinfo = c->argc == 3; /* Without the range just outputs general informations about the PEL. */ robj *key = c->argv[1]; robj *groupname = c->argv[2]; robj *consumername = (c->argc == 7) ? c->argv[6] : NULL; streamID startid, endid; long long count; /* Start and stop, and the consumer, can be omitted. */ if (c->argc != 3 && c->argc != 6 && c->argc != 7) { addReply(c,shared.syntaxerr); return; } /* Parse start/end/count arguments ASAP if needed, in order to report * syntax errors before any other error. */ if (c->argc >= 6) { if (getLongLongFromObjectOrReply(c,c->argv[5],&count,NULL) == C_ERR) return; if (streamParseIDOrReply(c,c->argv[3],&startid,0) == C_ERR) return; if (streamParseIDOrReply(c,c->argv[4],&endid,UINT64_MAX) == C_ERR) return; } /* Lookup the key and the group inside the stream. */ robj *o = lookupKeyRead(c->db,c->argv[1]); streamCG *group; if (o && checkType(c,o,OBJ_STREAM)) return; if (o == NULL || (group = streamLookupCG(o->ptr,groupname->ptr)) == NULL) { addReplyErrorFormat(c, "-NOGROUP No such key '%s' or consumer " "group '%s'", (char*)key->ptr,(char*)groupname->ptr); return; } /* XPENDING <key> <group> variant. */ if (justinfo) { addReplyMultiBulkLen(c,4); /* Total number of messages in the PEL. */ addReplyLongLong(c,raxSize(group->pel)); /* First and last IDs. */ if (raxSize(group->pel) == 0) { addReply(c,shared.nullbulk); /* Start. */ addReply(c,shared.nullbulk); /* End. */ addReply(c,shared.nullmultibulk); /* Clients. */ } else { /* Start. */ raxIterator ri; raxStart(&ri,group->pel); raxSeek(&ri,"^",NULL,0); raxNext(&ri); streamDecodeID(ri.key,&startid); addReplyStreamID(c,&startid); /* End. */ raxSeek(&ri,"$",NULL,0); raxNext(&ri); streamDecodeID(ri.key,&endid); addReplyStreamID(c,&endid); raxStop(&ri); /* Consumers with pending messages. */ raxStart(&ri,group->consumers); raxSeek(&ri,"^",NULL,0); void *arraylen_ptr = addDeferredMultiBulkLength(c); size_t arraylen = 0; while(raxNext(&ri)) { streamConsumer *consumer = ri.data; if (raxSize(consumer->pel) == 0) continue; addReplyMultiBulkLen(c,2); addReplyBulkCBuffer(c,ri.key,ri.key_len); addReplyBulkLongLong(c,raxSize(consumer->pel)); arraylen++; } setDeferredMultiBulkLength(c,arraylen_ptr,arraylen); raxStop(&ri); } } /* XPENDING <key> <group> <start> <stop> <count> [<consumer>] variant. */ else { streamConsumer *consumer = consumername ? streamLookupConsumer(group,consumername->ptr,0): NULL; /* If a consumer name was mentioned but it does not exist, we can * just return an empty array. */ if (consumername && consumer == NULL) { addReplyMultiBulkLen(c,0); return; } rax *pel = consumer ? consumer->pel : group->pel; unsigned char startkey[sizeof(streamID)]; unsigned char endkey[sizeof(streamID)]; raxIterator ri; mstime_t now = mstime(); streamEncodeID(startkey,&startid); streamEncodeID(endkey,&endid); raxStart(&ri,pel); raxSeek(&ri,">=",startkey,sizeof(startkey)); void *arraylen_ptr = addDeferredMultiBulkLength(c); size_t arraylen = 0; while(count && raxNext(&ri) && memcmp(ri.key,endkey,ri.key_len) <= 0) { streamNACK *nack = ri.data; arraylen++; count--; addReplyMultiBulkLen(c,4); /* Entry ID. */ streamID id; streamDecodeID(ri.key,&id); addReplyStreamID(c,&id); /* Consumer name. */ addReplyBulkCBuffer(c,nack->consumer->name, sdslen(nack->consumer->name)); /* Milliseconds elapsed since last delivery. */ mstime_t elapsed = now - nack->delivery_time; if (elapsed < 0) elapsed = 0; addReplyLongLong(c,elapsed); /* Number of deliveries. */ addReplyLongLong(c,nack->delivery_count); } raxStop(&ri); setDeferredMultiBulkLength(c,arraylen_ptr,arraylen); } }
0
[ "CWE-125", "CWE-704" ]
redis
c04082cf138f1f51cedf05ee9ad36fb6763cafc6
96,433,059,014,075,000,000,000,000,000,000,000,000
137
Abort in XGROUP if the key is not a stream
String *Item_default_value::val_str(String *str) { calculate(); return Item_field::val_str(str); }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
2,234,399,753,003,986,600,000,000,000,000,000,000
5
MDEV-24176 Preparations 1. moved fix_vcol_exprs() call to open_table() mysql_alter_table() doesn't do lock_tables() so it cannot win from fix_vcol_exprs() from there. Tests affected: main.default_session 2. Vanilla cleanups and comments.
static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req) { struct inet_request_sock *ireq = inet_rsk(req); struct ipv6_pinfo *np = inet6_sk(sk); struct sk_buff *skb; struct in6_addr *final_p, final; struct flowi6 fl6; int err = -1; struct dst_entry *dst; memset(&fl6, 0, sizeof(fl6)); fl6.flowi6_proto = IPPROTO_DCCP; fl6.daddr = ireq->ir_v6_rmt_addr; fl6.saddr = ireq->ir_v6_loc_addr; fl6.flowlabel = 0; fl6.flowi6_oif = ireq->ir_iif; fl6.fl6_dport = ireq->ir_rmt_port; fl6.fl6_sport = htons(ireq->ir_num); security_req_classify_flow(req, flowi6_to_flowi(&fl6)); rcu_read_lock(); final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final); rcu_read_unlock(); dst = ip6_dst_lookup_flow(sk, &fl6, final_p); if (IS_ERR(dst)) { err = PTR_ERR(dst); dst = NULL; goto done; } skb = dccp_make_response(sk, dst, req); if (skb != NULL) { struct dccp_hdr *dh = dccp_hdr(skb); struct ipv6_txoptions *opt; dh->dccph_checksum = dccp_v6_csum_finish(skb, &ireq->ir_v6_loc_addr, &ireq->ir_v6_rmt_addr); fl6.daddr = ireq->ir_v6_rmt_addr; rcu_read_lock(); opt = ireq->ipv6_opt; if (!opt) opt = rcu_dereference(np->opt); err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass); rcu_read_unlock(); err = net_xmit_eval(err); } done: dst_release(dst); return err; }
0
[ "CWE-241" ]
linux
83eaddab4378db256d00d295bda6ca997cd13a52
166,962,443,636,706,360,000,000,000,000,000,000,000
54
ipv6/dccp: do not inherit ipv6_mc_list from parent Like commit 657831ffc38e ("dccp/tcp: do not inherit mc_list from parent") we should clear ipv6_mc_list etc. for IPv6 sockets too. Cc: Eric Dumazet <[email protected]> Signed-off-by: Cong Wang <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl) { const struct flowi4 *fl4 = &fl->u.ip4; return addr4_match(fl4->daddr, sel->daddr.a4, sel->prefixlen_d) && addr4_match(fl4->saddr, sel->saddr.a4, sel->prefixlen_s) && !((xfrm_flowi_dport(fl, &fl4->uli) ^ sel->dport) & sel->dport_mask) && !((xfrm_flowi_sport(fl, &fl4->uli) ^ sel->sport) & sel->sport_mask) && (fl4->flowi4_proto == sel->proto || !sel->proto) && (fl4->flowi4_oif == sel->ifindex || !sel->ifindex); }
0
[ "CWE-125" ]
ipsec
7bab09631c2a303f87a7eb7e3d69e888673b9b7e
284,598,321,992,164,880,000,000,000,000,000,000,000
11
xfrm: policy: check policy direction value The 'dir' parameter in xfrm_migrate() is a user-controlled byte which is used as an array index. This can lead to an out-of-bound access, kernel lockup and DoS. Add a check for the 'dir' value. This fixes CVE-2017-11600. References: https://bugzilla.redhat.com/show_bug.cgi?id=1474928 Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)") Cc: <[email protected]> # v2.6.21-rc1 Reported-by: "bo Zhang" <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
node_new_true_anychar(Node** node, ScanEnv* env) { Node* n; n = node_new_anychar_with_fixed_option(ONIG_OPTION_MULTILINE); CHECK_NULL_RETURN_MEMERR(n); *node = n; return 0; }
0
[ "CWE-400", "CWE-399", "CWE-674" ]
oniguruma
4097828d7cc87589864fecf452f2cd46c5f37180
178,850,342,483,068,300,000,000,000,000,000,000,000
9
fix #147: Stack Exhaustion Problem caused by some parsing functions in regcomp.c making recursive calls to themselves.
static int write_entry(struct mailbox *mailbox, unsigned int uid, const char *entry, const char *userid, const struct buf *value, int ignorequota, int silent, const struct annotate_metadata *mdata, int maywrite) { char key[MAX_MAILBOX_PATH+1]; int keylen, r; annotate_db_t *d = NULL; struct buf oldval = BUF_INITIALIZER; const char *mboxname = mailbox ? mailbox->name : ""; modseq_t modseq = mdata ? mdata->modseq : 0; r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d); if (r) return r; /* must be in a transaction to modify the db */ annotate_begin(d); keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key)); struct annotate_metadata oldmdata; r = read_old_value(d, key, keylen, &oldval, &oldmdata); if (r) goto out; /* if the value is identical, don't touch the mailbox */ if (oldval.len == value->len && (!value->len || !memcmp(oldval.s, value->s, value->len))) goto out; if (!maywrite) { r = IMAP_PERMISSION_DENIED; if (r) goto out; } if (mailbox) { if (!ignorequota) { quota_t qdiffs[QUOTA_NUMRESOURCES] = QUOTA_DIFFS_DONTCARE_INITIALIZER; qdiffs[QUOTA_ANNOTSTORAGE] = value->len - (quota_t)oldval.len; r = mailbox_quota_check(mailbox, qdiffs); if (r) goto out; } /* do the annot-changed here before altering the DB */ mailbox_annot_changed(mailbox, uid, entry, userid, &oldval, value, silent); /* grab the message annotation modseq, if not overridden */ if (uid && !mdata) { modseq = mailbox->i.highestmodseq; } } /* zero length annotation is deletion. * keep tombstones for message annotations */ if (!value->len && !uid) { #if DEBUG syslog(LOG_ERR, "write_entry: deleting key %s from %s", key_as_string(d, key, keylen), d->filename); #endif do { r = cyrusdb_delete(d->db, key, keylen, tid(d), /*force*/1); } while (r == CYRUSDB_AGAIN); } else { struct buf data = BUF_INITIALIZER; unsigned char flags = 0; if (!value->len || value->s == NULL) { flags |= ANNOTATE_FLAG_DELETED; } else { // this is only here to allow cleanup of invalid values in the past... // the calling of this API with a NULL "userid" is bogus, because that's // supposed to be reserved for the make_key of prefixes - but there has // been API abuse in the past, so some of these are in the wild. *sigh*. // Don't allow new ones to be written if (!userid) goto out; } make_entry(&data, value, modseq, flags); #if DEBUG syslog(LOG_ERR, "write_entry: storing key %s (value: %s) to %s (modseq=" MODSEQ_FMT ")", key_as_string(d, key, keylen), value->s, d->filename, modseq); #endif do { r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d)); } while (r == CYRUSDB_AGAIN); buf_free(&data); } if (!mailbox) sync_log_annotation(""); out: annotate_putdb(&d); buf_free(&oldval); return r; }
0
[ "CWE-732" ]
cyrus-imapd
621f9e41465b521399f691c241181300fab55995
99,776,951,460,311,700,000,000,000,000,000,000,000
106
annotate: don't allow everyone to write shared server entries
int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) { struct iphdr *iph; int ptr; struct net_device *dev; struct sk_buff *skb2; unsigned int mtu, hlen, left, len, ll_rs; int offset; __be16 not_last_frag; struct rtable *rt = skb_rtable(skb); int err = 0; dev = rt->dst.dev; /* * Point into the IP datagram header. */ iph = ip_hdr(skb); if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->local_df) || (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size > dst_mtu(&rt->dst)))) { IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(ip_skb_dst_mtu(skb))); kfree_skb(skb); return -EMSGSIZE; } /* * Setup starting values. */ hlen = iph->ihl * 4; mtu = dst_mtu(&rt->dst) - hlen; /* Size of data space */ #ifdef CONFIG_BRIDGE_NETFILTER if (skb->nf_bridge) mtu -= nf_bridge_mtu_reduction(skb); #endif IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; /* When frag_list is given, use it. First, check its validity: * some transformers could create wrong frag_list or break existing * one, it is not prohibited. In this case fall back to copying. * * LATER: this step can be merged to real generation of fragments, * we can switch to copy when see the first bad fragment. */ if (skb_has_frag_list(skb)) { struct sk_buff *frag, *frag2; int first_len = skb_pagelen(skb); if (first_len - hlen > mtu || ((first_len - hlen) & 7) || ip_is_fragment(iph) || skb_cloned(skb)) goto slow_path; skb_walk_frags(skb, frag) { /* Correct geometry. */ if (frag->len > mtu || ((frag->len & 7) && frag->next) || skb_headroom(frag) < hlen) goto slow_path_clean; /* Partially cloned skb? */ if (skb_shared(frag)) goto slow_path_clean; BUG_ON(frag->sk); if (skb->sk) { frag->sk = skb->sk; frag->destructor = sock_wfree; } skb->truesize -= frag->truesize; } /* Everything is OK. Generate! */ err = 0; offset = 0; frag = skb_shinfo(skb)->frag_list; skb_frag_list_init(skb); skb->data_len = first_len - skb_headlen(skb); skb->len = first_len; iph->tot_len = htons(first_len); iph->frag_off = htons(IP_MF); ip_send_check(iph); for (;;) { /* Prepare header of the next frame, * before previous one went down. */ if (frag) { frag->ip_summed = CHECKSUM_NONE; skb_reset_transport_header(frag); __skb_push(frag, hlen); skb_reset_network_header(frag); memcpy(skb_network_header(frag), iph, hlen); iph = ip_hdr(frag); iph->tot_len = htons(frag->len); ip_copy_metadata(frag, skb); if (offset == 0) ip_options_fragment(frag); offset += skb->len - hlen; iph->frag_off = htons(offset>>3); if (frag->next != NULL) iph->frag_off |= htons(IP_MF); /* Ready, complete checksum */ ip_send_check(iph); } err = output(skb); if (!err) IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES); if (err || !frag) break; skb = frag; frag = skb->next; skb->next = NULL; } if (err == 0) { IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS); return 0; } while (frag) { skb = frag->next; kfree_skb(frag); frag = skb; } IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); return err; slow_path_clean: skb_walk_frags(skb, frag2) { if (frag2 == frag) break; frag2->sk = NULL; frag2->destructor = NULL; skb->truesize += frag2->truesize; } } slow_path: /* for offloaded checksums cleanup checksum before fragmentation */ if ((skb->ip_summed == CHECKSUM_PARTIAL) && skb_checksum_help(skb)) goto fail; iph = ip_hdr(skb); left = skb->len - hlen; /* Space per frame */ ptr = hlen; /* Where to start from */ /* for bridged IP traffic encapsulated inside f.e. a vlan header, * we need to make room for the encapsulating header */ ll_rs = LL_RESERVED_SPACE_EXTRA(rt->dst.dev, nf_bridge_pad(skb)); /* * Fragment the datagram. */ offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; not_last_frag = iph->frag_off & htons(IP_MF); /* * Keep copying data until we run out. */ while (left > 0) { len = left; /* IF: it doesn't fit, use 'mtu' - the data space left */ if (len > mtu) len = mtu; /* IF: we are not sending up to and including the packet end then align the next start on an eight byte boundary */ if (len < left) { len &= ~7; } /* * Allocate buffer. */ if ((skb2 = alloc_skb(len+hlen+ll_rs, GFP_ATOMIC)) == NULL) { NETDEBUG(KERN_INFO "IP: frag: no memory for new fragment!\n"); err = -ENOMEM; goto fail; } /* * Set up data on packet */ ip_copy_metadata(skb2, skb); skb_reserve(skb2, ll_rs); skb_put(skb2, len + hlen); skb_reset_network_header(skb2); skb2->transport_header = skb2->network_header + hlen; /* * Charge the memory for the fragment to any owner * it might possess */ if (skb->sk) skb_set_owner_w(skb2, skb->sk); /* * Copy the packet header into the new buffer. */ skb_copy_from_linear_data(skb, skb_network_header(skb2), hlen); /* * Copy a block of the IP datagram. */ if (skb_copy_bits(skb, ptr, skb_transport_header(skb2), len)) BUG(); left -= len; /* * Fill in the new header fields. */ iph = ip_hdr(skb2); iph->frag_off = htons((offset >> 3)); /* ANK: dirty, but effective trick. Upgrade options only if * the segment to be fragmented was THE FIRST (otherwise, * options are already fixed) and make it ONCE * on the initial skb, so that all the following fragments * will inherit fixed options. */ if (offset == 0) ip_options_fragment(skb); /* * Added AC : If we are fragmenting a fragment that's not the * last fragment then keep MF on each bit */ if (left > 0 || not_last_frag) iph->frag_off |= htons(IP_MF); ptr += len; offset += len; /* * Put this fragment into the sending queue. */ iph->tot_len = htons(len + hlen); ip_send_check(iph); err = output(skb2); if (err) goto fail; IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGCREATES); } consume_skb(skb); IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGOKS); return err; fail: kfree_skb(skb); IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); return err; }
0
[ "CWE-284", "CWE-264" ]
linux
e93b7d748be887cd7639b113ba7d7ef792a7efb9
211,545,677,618,372,960,000,000,000,000,000,000,000
269
ip_output: do skb ufo init for peeked non ufo skb as well Now, if user application does: sendto len<mtu flag MSG_MORE sendto len>mtu flag 0 The skb is not treated as fragmented one because it is not initialized that way. So move the initialization to fix this. introduced by: commit e89e9cf539a28df7d0eb1d0a545368e9920b34ac "[IPv4/IPv6]: UFO Scatter-gather approach" Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
ignore_tty_job_signals () { set_signal_handler (SIGTSTP, SIG_IGN); set_signal_handler (SIGTTIN, SIG_IGN); set_signal_handler (SIGTTOU, SIG_IGN); }
0
[]
bash
955543877583837c85470f7fb8a97b7aa8d45e6c
103,567,693,656,586,620,000,000,000,000,000,000,000
6
bash-4.4-rc2 release
static int shmem_writepage(struct page *page, struct writeback_control *wbc) { struct shmem_inode_info *info; swp_entry_t *entry, swap; struct address_space *mapping; unsigned long index; struct inode *inode; BUG_ON(!PageLocked(page)); mapping = page->mapping; index = page->index; inode = mapping->host; info = SHMEM_I(inode); if (info->flags & VM_LOCKED) goto redirty; if (!total_swap_pages) goto redirty; /* * shmem_backing_dev_info's capabilities prevent regular writeback or * sync from ever calling shmem_writepage; but a stacking filesystem * may use the ->writepage of its underlying filesystem, in which case * tmpfs should write out to swap only in response to memory pressure, * and not for pdflush or sync. However, in those cases, we do still * want to check if there's a redundant swappage to be discarded. */ if (wbc->for_reclaim) swap = get_swap_page(); else swap.val = 0; spin_lock(&info->lock); if (index >= info->next_index) { BUG_ON(!(info->flags & SHMEM_TRUNCATE)); goto unlock; } entry = shmem_swp_entry(info, index, NULL); if (entry->val) { /* * The more uptodate page coming down from a stacked * writepage should replace our old swappage. */ free_swap_and_cache(*entry); shmem_swp_set(info, entry, 0); } shmem_recalc_inode(inode); if (swap.val && add_to_swap_cache(page, swap, GFP_ATOMIC) == 0) { remove_from_page_cache(page); shmem_swp_set(info, entry, swap.val); shmem_swp_unmap(entry); if (list_empty(&info->swaplist)) inode = igrab(inode); else inode = NULL; spin_unlock(&info->lock); swap_duplicate(swap); BUG_ON(page_mapped(page)); page_cache_release(page); /* pagecache ref */ set_page_dirty(page); unlock_page(page); if (inode) { mutex_lock(&shmem_swaplist_mutex); /* move instead of add in case we're racing */ list_move_tail(&info->swaplist, &shmem_swaplist); mutex_unlock(&shmem_swaplist_mutex); iput(inode); } return 0; } shmem_swp_unmap(entry); unlock: spin_unlock(&info->lock); swap_free(swap); redirty: set_page_dirty(page); if (wbc->for_reclaim) return AOP_WRITEPAGE_ACTIVATE; /* Return with page locked */ unlock_page(page); return 0; }
0
[ "CWE-400" ]
linux-2.6
14fcc23fdc78e9d32372553ccf21758a9bd56fa1
236,231,068,260,320,380,000,000,000,000,000,000,000
82
tmpfs: fix kernel BUG in shmem_delete_inode SuSE's insserve initscript ordering program hits kernel BUG at mm/shmem.c:814 on 2.6.26. It's using posix_fadvise on directories, and the shmem_readpage method added in 2.6.23 is letting POSIX_FADV_WILLNEED allocate useless pages to a tmpfs directory, incrementing i_blocks count but never decrementing it. Fix this by assigning shmem_aops (pointing to readpage and writepage and set_page_dirty) only when it's needed, on a regular file or a long symlink. Many thanks to Kel for outstanding bugreport and steps to reproduce it. Reported-by: Kel Modderman <[email protected]> Tested-by: Kel Modderman <[email protected]> Signed-off-by: Hugh Dickins <[email protected]> Cc: <[email protected]> [2.6.25.x, 2.6.26.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void __sdt_free(const struct cpumask *cpu_map) { struct sched_domain_topology_level *tl; int j; for_each_sd_topology(tl) { struct sd_data *sdd = &tl->data; for_each_cpu(j, cpu_map) { struct sched_domain *sd; if (sdd->sd) { sd = *per_cpu_ptr(sdd->sd, j); if (sd && (sd->flags & SD_OVERLAP)) free_sched_groups(sd->groups, 0); kfree(*per_cpu_ptr(sdd->sd, j)); } if (sdd->sg) kfree(*per_cpu_ptr(sdd->sg, j)); if (sdd->sgp) kfree(*per_cpu_ptr(sdd->sgp, j)); } free_percpu(sdd->sd); sdd->sd = NULL; free_percpu(sdd->sg); sdd->sg = NULL; free_percpu(sdd->sgp); sdd->sgp = NULL; } }
0
[ "CWE-200" ]
linux
4efbc454ba68def5ef285b26ebfcfdb605b52755
97,332,789,929,708,120,000,000,000,000,000,000,000
31
sched: Fix information leak in sys_sched_getattr() We're copying the on-stack structure to userspace, but forgot to give the right number of bytes to copy. This allows the calling process to obtain up to PAGE_SIZE bytes from the stack (and possibly adjacent kernel memory). This fix copies only as much as we actually have on the stack (attr->size defaults to the size of the struct) and leaves the rest of the userspace-provided buffer untouched. Found using kmemcheck + trinity. Fixes: d50dde5a10f30 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI") Cc: Dario Faggioli <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Vegard Nossum <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
static int json_parse_atom(struct json_parser *parser, const char *atom) { size_t avail, len = strlen(atom); avail = parser->end - parser->data; if (avail < len) { if (memcmp(parser->data, atom, avail) != 0) return -1; /* everything matches so far, but we need more data */ parser->data += avail; return 0; } if (memcmp(parser->data, atom, len) != 0) return -1; parser->data += len; return 1; }
0
[]
core
973769d74433de3c56c4ffdf4f343cb35d98e4f7
280,666,666,860,672,830,000,000,000,000,000,000,000
18
lib: json - Escape invalid UTF-8 as unicode bytes This prevents dovecot from crashing if invalid UTF-8 input is given.
isdn_ppp_wakeup_daemon(isdn_net_local *lp) { if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { printk(KERN_ERR "%s: ppp_slot(%d) out of range\n", __func__, lp->ppp_slot); return; } ippp_table[lp->ppp_slot]->state = IPPP_OPEN | IPPP_CONNECT | IPPP_NOBLOCK; wake_up_interruptible(&ippp_table[lp->ppp_slot]->wq); }
0
[]
linux
4ab42d78e37a294ac7bc56901d563c642e03c4ae
18,459,834,887,014,847,000,000,000,000,000,000,000
10
ppp, slip: Validate VJ compression slot parameters completely Currently slhc_init() treats out-of-range values of rslots and tslots as equivalent to 0, except that if tslots is too large it will dereference a null pointer (CVE-2015-7799). Add a range-check at the top of the function and make it return an ERR_PTR() on error instead of NULL. Change the callers accordingly. Compile-tested only. Reported-by: 郭永刚 <[email protected]> References: http://article.gmane.org/gmane.comp.security.oss.general/17908 Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
gdev_x_open(gx_device_X * xdev) { XSizeHints sizehints; char *window_id; XEvent event; XVisualInfo xvinfo; int nitems; XtAppContext app_con; Widget toplevel; Display *dpy; XColor xc; int zero = 0; int xid_height = 0, xid_width = 0; int code; #ifdef DEBUG # ifdef have_Xdebug if (gs_debug['X']) { extern int _Xdebug; _Xdebug = 1; } # endif #endif if (!(xdev->dpy = XOpenDisplay((char *)NULL))) { char *dispname = getenv("DISPLAY"); emprintf1(xdev->memory, "Cannot open X display `%s'.\n", (dispname == NULL ? "(null)" : dispname)); return_error(gs_error_ioerror); } xdev->dest = 0; if ((window_id = getenv("GHOSTVIEW"))) { if (!(xdev->ghostview = sscanf(window_id, "%ld %ld", &(xdev->win), &(xdev->dest)))) { emprintf(xdev->memory, "Cannot get Window ID from ghostview.\n"); return_error(gs_error_ioerror); } } if (xdev->pwin != (Window) None) { /* pick up the destination window parameters if specified */ XWindowAttributes attrib; xdev->win = xdev->pwin; if (XGetWindowAttributes(xdev->dpy, xdev->win, &attrib)) { xdev->scr = attrib.screen; xvinfo.visual = attrib.visual; xdev->cmap = attrib.colormap; xid_width = attrib.width; xid_height = attrib.height; } else { /* No idea why we can't get the attributes, but */ /* we shouldn't let it lead to a failure below. */ xid_width = xid_height = 0; } } else if (xdev->ghostview) { XWindowAttributes attrib; Atom type; int format; unsigned long nitems, bytes_after; char *buf; Atom ghostview_atom = XInternAtom(xdev->dpy, "GHOSTVIEW", False); if (XGetWindowAttributes(xdev->dpy, xdev->win, &attrib)) { xdev->scr = attrib.screen; xvinfo.visual = attrib.visual; xdev->cmap = attrib.colormap; xdev->width = attrib.width; xdev->height = attrib.height; } /* Delete property if explicit dest is given */ if (XGetWindowProperty(xdev->dpy, xdev->win, ghostview_atom, 0, 256, (xdev->dest != 0), XA_STRING, &type, &format, &nitems, &bytes_after, (unsigned char **)&buf) == 0 && type == XA_STRING) { int llx, lly, urx, ury; int left_margin = 0, bottom_margin = 0; int right_margin = 0, top_margin = 0; /* We declare page_orientation as an int so that we can */ /* use an int * to reference it for sscanf; compilers */ /* might be tempted to use less space to hold it if */ /* it were declared as an orientation. */ int /*orientation */ page_orientation; float xppp, yppp; /* pixels per point */ nitems = sscanf(buf, "%ld %d %d %d %d %d %f %f %d %d %d %d", &(xdev->bpixmap), &page_orientation, &llx, &lly, &urx, &ury, &(xdev->x_pixels_per_inch), &(xdev->y_pixels_per_inch), &left_margin, &bottom_margin, &right_margin, &top_margin); if (!(nitems == 8 || nitems == 12)) { emprintf(xdev->memory, "Cannot get ghostview property.\n"); return_error(gs_error_ioerror); } if (xdev->dest && xdev->bpixmap) { emprintf(xdev->memory, "Both destination and backing pixmap specified.\n"); return_error(gs_error_rangecheck); } if (xdev->dest) { Window root; int x, y; unsigned int width, height; unsigned int border_width, depth; if (XGetGeometry(xdev->dpy, xdev->dest, &root, &x, &y, &width, &height, &border_width, &depth)) { xdev->width = width; xdev->height = height; } } xppp = xdev->x_pixels_per_inch / 72.0; yppp = xdev->y_pixels_per_inch / 72.0; switch (page_orientation) { case Portrait: xdev->initial_matrix.xx = xppp; xdev->initial_matrix.xy = 0.0; xdev->initial_matrix.yx = 0.0; xdev->initial_matrix.yy = -yppp; xdev->initial_matrix.tx = -llx * xppp; xdev->initial_matrix.ty = ury * yppp; break; case Landscape: xdev->initial_matrix.xx = 0.0; xdev->initial_matrix.xy = yppp; xdev->initial_matrix.yx = xppp; xdev->initial_matrix.yy = 0.0; xdev->initial_matrix.tx = -lly * xppp; xdev->initial_matrix.ty = -llx * yppp; break; case Upsidedown: xdev->initial_matrix.xx = -xppp; xdev->initial_matrix.xy = 0.0; xdev->initial_matrix.yx = 0.0; xdev->initial_matrix.yy = yppp; xdev->initial_matrix.tx = urx * xppp; xdev->initial_matrix.ty = -lly * yppp; break; case Seascape: xdev->initial_matrix.xx = 0.0; xdev->initial_matrix.xy = -yppp; xdev->initial_matrix.yx = -xppp; xdev->initial_matrix.yy = 0.0; xdev->initial_matrix.tx = ury * xppp; xdev->initial_matrix.ty = urx * yppp; break; } /* The following sets the imageable area according to the */ /* bounding box and margins sent by ghostview. */ /* This code has been patched many times; its current state */ /* is per a recommendation by Tim Theisen on 4/28/95. */ xdev->ImagingBBox[0] = llx - left_margin; xdev->ImagingBBox[1] = lly - bottom_margin; xdev->ImagingBBox[2] = urx + right_margin; xdev->ImagingBBox[3] = ury + top_margin; xdev->ImagingBBox_set = true; } else if (xdev->pwin == (Window) None) { emprintf(xdev->memory, "Cannot get ghostview property.\n"); return_error(gs_error_ioerror); } } else { Screen *scr = DefaultScreenOfDisplay(xdev->dpy); xdev->scr = scr; xvinfo.visual = DefaultVisualOfScreen(scr); xdev->cmap = DefaultColormapOfScreen(scr); if (xvinfo.visual->class != TrueColor) { int scrno = DefaultScreen(xdev->dpy); if ( XMatchVisualInfo(xdev->dpy, scrno, 24, TrueColor, &xvinfo) || XMatchVisualInfo(xdev->dpy, scrno, 32, TrueColor, &xvinfo) || XMatchVisualInfo(xdev->dpy, scrno, 16, TrueColor, &xvinfo) || XMatchVisualInfo(xdev->dpy, scrno, 15, TrueColor, &xvinfo) ) { xdev->cmap = XCreateColormap (xdev->dpy, DefaultRootWindow(xdev->dpy), xvinfo.visual, AllocNone ); } } } xvinfo.visualid = XVisualIDFromVisual(xvinfo.visual); xdev->vinfo = XGetVisualInfo(xdev->dpy, VisualIDMask, &xvinfo, &nitems); if (xdev->vinfo == NULL) { emprintf(xdev->memory, "Cannot get XVisualInfo.\n"); return_error(gs_error_ioerror); } /* Buggy X servers may cause a Bad Access on XFreeColors. */ if (!x_error_handler.set) { x_error_handler.orighandler = XSetErrorHandler(x_catch_free_colors); x_error_handler.set = True; } /* Get X Resources. Use the toolkit for this. */ XtToolkitInitialize(); app_con = XtCreateApplicationContext(); XtAppSetFallbackResources(app_con, gdev_x_fallback_resources); dpy = XtOpenDisplay(app_con, NULL, "ghostscript", "Ghostscript", NULL, 0, &zero, NULL); toplevel = XtAppCreateShell(NULL, "Ghostscript", applicationShellWidgetClass, dpy, NULL, 0); XtGetApplicationResources(toplevel, (XtPointer) xdev, gdev_x_resources, gdev_x_resource_count, NULL, 0); /* Reserve foreground and background colors under the regular connection. */ xc.pixel = xdev->foreground; XQueryColor(xdev->dpy, DefaultColormap(xdev->dpy,DefaultScreen(xdev->dpy)), &xc); XAllocColor(xdev->dpy, xdev->cmap, &xc); xdev->foreground = xc.pixel; xc.pixel = xdev->background; XQueryColor(xdev->dpy, DefaultColormap(xdev->dpy,DefaultScreen(xdev->dpy)), &xc); XAllocColor(xdev->dpy, xdev->cmap, &xc); xdev->background = xc.pixel; code = gdev_x_setup_colors(xdev); if (code < 0) { XCloseDisplay(xdev->dpy); return code; } /* Now that the color map is setup check if the device is separable. */ check_device_separable((gx_device *)xdev); if (!xdev->ghostview) { XWMHints wm_hints; XClassHint class_hint; XSetWindowAttributes xswa; gx_device *dev = (gx_device *) xdev; /* Take care of resolution and paper size. */ if (xdev->x_pixels_per_inch == FAKE_RES || xdev->y_pixels_per_inch == FAKE_RES) { float xsize = (float)xdev->width / xdev->x_pixels_per_inch; float ysize = (float)xdev->height / xdev->y_pixels_per_inch; int workarea_width = WidthOfScreen(xdev->scr), workarea_height = HeightOfScreen(xdev->scr); /* Get area available for windows placement */ x_get_work_area(xdev, &workarea_width, &workarea_height); if (xdev->xResolution == 0.0 && xdev->yResolution == 0.0) { float dpi, xdpi, ydpi; xdpi = 25.4 * WidthOfScreen(xdev->scr) / WidthMMOfScreen(xdev->scr); ydpi = 25.4 * HeightOfScreen(xdev->scr) / HeightMMOfScreen(xdev->scr); dpi = min(xdpi, ydpi); /* * Some X servers provide very large "virtual screens", and * return the virtual screen size for Width/HeightMM but the * physical size for Width/Height. Attempt to detect and * correct for this now. This is a KLUDGE required because * the X server provides no way to read the screen * resolution directly. */ if (dpi < 30) dpi = 75; /* arbitrary */ else { while (xsize * dpi > WidthOfScreen(xdev->scr) - 32 || ysize * dpi > HeightOfScreen(xdev->scr) - 32) dpi *= 0.95; } xdev->x_pixels_per_inch = dpi; xdev->y_pixels_per_inch = dpi; } else { xdev->x_pixels_per_inch = xdev->xResolution; xdev->y_pixels_per_inch = xdev->yResolution; } /* Restrict maximum window size to available work area */ if (xdev->width > workarea_width) { xdev->width = min(xsize * xdev->x_pixels_per_inch, workarea_width); } if (xdev->height > workarea_height) { xdev->height = min(ysize * xdev->y_pixels_per_inch, workarea_height); } xdev->MediaSize[0] = (float)xdev->width / xdev->x_pixels_per_inch * 72; xdev->MediaSize[1] = (float)xdev->height / xdev->y_pixels_per_inch * 72; } sizehints.x = 0; sizehints.y = 0; sizehints.width = xdev->width; sizehints.height = xdev->height; sizehints.flags = 0; if (xdev->geometry != NULL) { /* * Note that border_width must be set first. We can't use * scr, because that is a Screen*, and XWMGeometry wants * the screen number. */ char gstr[40]; int bitmask; gs_sprintf(gstr, "%dx%d+%d+%d", sizehints.width, sizehints.height, sizehints.x, sizehints.y); bitmask = XWMGeometry(xdev->dpy, DefaultScreen(xdev->dpy), xdev->geometry, gstr, xdev->borderWidth, &sizehints, &sizehints.x, &sizehints.y, &sizehints.width, &sizehints.height, &sizehints.win_gravity); if (bitmask & (XValue | YValue)) sizehints.flags |= USPosition; } gx_default_get_initial_matrix(dev, &(xdev->initial_matrix)); if (xdev->pwin != (Window) None && xid_width != 0 && xid_height != 0) { #if 0 /*************** */ /* * The user who originally implemented the WindowID feature * provided the following code to scale the displayed output * to fit in the window. We think this is a bad idea, * since it doesn't track window resizing and is generally * completely at odds with the way Ghostscript treats * window or paper size in all other contexts. We are * leaving the code here in case someone decides that * this really is the behavior they want. */ /* Scale to fit in the window. */ xdev->initial_matrix.xx = xdev->initial_matrix.xx * (float)xid_width / (float)xdev->width; xdev->initial_matrix.yy = xdev->initial_matrix.yy * (float)xid_height / (float)xdev->height; #endif /*************** */ xdev->width = xid_width; xdev->height = xid_height; xdev->initial_matrix.ty = xdev->height; } else { /* !xdev->pwin */ xswa.event_mask = ExposureMask; xswa.background_pixel = xdev->background; xswa.border_pixel = xdev->borderColor; xswa.colormap = xdev->cmap; xdev->win = XCreateWindow(xdev->dpy, RootWindowOfScreen(xdev->scr), sizehints.x, sizehints.y, /* upper left */ xdev->width, xdev->height, xdev->borderWidth, xdev->vinfo->depth, InputOutput, /* class */ xdev->vinfo->visual, /* visual */ CWEventMask | CWBackPixel | CWBorderPixel | CWColormap, &xswa); XStoreName(xdev->dpy, xdev->win, "ghostscript"); XSetWMNormalHints(xdev->dpy, xdev->win, &sizehints); wm_hints.flags = InputHint; wm_hints.input = False; XSetWMHints(xdev->dpy, xdev->win, &wm_hints); /* avoid input focus */ class_hint.res_name = (char *)"ghostscript"; class_hint.res_class = (char *)"Ghostscript"; XSetClassHint(xdev->dpy, xdev->win, &class_hint); } } /*** *** According to Ricard Torres ([email protected]), we have to wait until here *** to close the toolkit connection, which we formerly did *** just after the calls on XAllocColor above. I suspect that *** this will cause things to be left dangling if an error occurs *** anywhere in the above code, but I'm willing to let users *** fight over fixing it, since I have no idea what's right. ***/ /* And close the toolkit connection. */ XtDestroyWidget(toplevel); XtCloseDisplay(dpy); XtDestroyApplicationContext(app_con); xdev->ht.pixmap = (Pixmap) 0; xdev->ht.id = gx_no_bitmap_id;; xdev->fill_style = FillSolid; xdev->function = GXcopy; xdev->fid = (Font) 0; /* Set up a graphics context */ xdev->gc = XCreateGC(xdev->dpy, xdev->win, 0, (XGCValues *) NULL); XSetFunction(xdev->dpy, xdev->gc, GXcopy); XSetLineAttributes(xdev->dpy, xdev->gc, 0, LineSolid, CapButt, JoinMiter); gdev_x_clear_window(xdev); if (!xdev->ghostview) { /* Make the window appear. */ XMapWindow(xdev->dpy, xdev->win); /* Before anything else, do a flush and wait for */ /* an exposure event. */ XSync(xdev->dpy, False); if (xdev->pwin == (Window) None) { /* there isn't a next event for existing windows */ XNextEvent(xdev->dpy, &event); } /* Now turn off graphics exposure events so they don't queue up */ /* indefinitely. Also, since we can't do anything about real */ /* Expose events, mask them out. */ XSetGraphicsExposures(xdev->dpy, xdev->gc, False); XSelectInput(xdev->dpy, xdev->win, NoEventMask); } else { /* Create an unmapped window, that the window manager will ignore. * This invisible window will be used to receive "next page" * events from ghostview */ XSetWindowAttributes attributes; attributes.override_redirect = True; xdev->mwin = XCreateWindow(xdev->dpy, RootWindowOfScreen(xdev->scr), 0, 0, 1, 1, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attributes); xdev->NEXT = XInternAtom(xdev->dpy, "NEXT", False); xdev->PAGE = XInternAtom(xdev->dpy, "PAGE", False); xdev->DONE = XInternAtom(xdev->dpy, "DONE", False); } xdev->ht.no_pixmap = XCreatePixmap(xdev->dpy, xdev->win, 1, 1, xdev->vinfo->depth); return 0; }
0
[]
ghostpdl
c432131c3fdb2143e148e8ba88555f7f7a63b25e
182,632,494,559,683,960,000,000,000,000,000,000,000
428
Bug 699661: Avoid sharing pointers between pdf14 compositors If a copdevice is triggered when the pdf14 compositor is the device, we make a copy of the device, then throw an error because, by default we're only allowed to copy the device prototype - then freeing it calls the finalize, which frees several pointers shared with the parent. Make a pdf14 specific finish_copydevice() which NULLs the relevant pointers, before, possibly, throwing the same error as the default method. This also highlighted a problem with reopening the X11 devices, where a custom error handler could be replaced with itself, meaning it also called itself, and infifite recursion resulted. Keep a note of if the handler replacement has been done, and don't do it a second time.
ns_client_send(ns_client_t *client) { isc_result_t result; unsigned char *data; isc_buffer_t buffer = { .magic = 0 }; isc_region_t r; dns_compress_t cctx; bool cleanup_cctx = false; unsigned int render_opts; unsigned int preferred_glue; bool opt_included = false; size_t respsize; dns_aclenv_t *env; #ifdef HAVE_DNSTAP unsigned char zone[DNS_NAME_MAXWIRE]; dns_dtmsgtype_t dtmsgtype; isc_region_t zr; #endif /* HAVE_DNSTAP */ REQUIRE(NS_CLIENT_VALID(client)); if ((client->query.attributes & NS_QUERYATTR_ANSWERED) != 0) { return; } /* * XXXWPK TODO * Delay the response according to the -T delay option */ env = ns_interfacemgr_getaclenv(client->manager->interface->mgr); CTRACE("send"); if (client->message->opcode == dns_opcode_query && (client->attributes & NS_CLIENTATTR_RA) != 0) { client->message->flags |= DNS_MESSAGEFLAG_RA; } if ((client->attributes & NS_CLIENTATTR_WANTDNSSEC) != 0) { render_opts = 0; } else { render_opts = DNS_MESSAGERENDER_OMITDNSSEC; } preferred_glue = 0; if (client->view != NULL) { if (client->view->preferred_glue == dns_rdatatype_a) { preferred_glue = DNS_MESSAGERENDER_PREFER_A; } else if (client->view->preferred_glue == dns_rdatatype_aaaa) { preferred_glue = DNS_MESSAGERENDER_PREFER_AAAA; } } if (preferred_glue == 0) { if (isc_sockaddr_pf(&client->peeraddr) == AF_INET) { preferred_glue = DNS_MESSAGERENDER_PREFER_A; } else { preferred_glue = DNS_MESSAGERENDER_PREFER_AAAA; } } /* * Create an OPT for our reply. */ if ((client->attributes & NS_CLIENTATTR_WANTOPT) != 0) { result = ns_client_addopt(client, client->message, &client->opt); if (result != ISC_R_SUCCESS) { goto cleanup; } } client_allocsendbuf(client, &buffer, &data); result = dns_compress_init(&cctx, -1, client->mctx); if (result != ISC_R_SUCCESS) { goto cleanup; } if (client->peeraddr_valid && client->view != NULL) { isc_netaddr_t netaddr; dns_name_t *name = NULL; isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr); if (client->message->tsigkey != NULL) { name = &client->message->tsigkey->name; } if (client->view->nocasecompress == NULL || !dns_acl_allowed(&netaddr, name, client->view->nocasecompress, env)) { dns_compress_setsensitive(&cctx, true); } if (!client->view->msgcompression) { dns_compress_disable(&cctx); } } cleanup_cctx = true; result = dns_message_renderbegin(client->message, &cctx, &buffer); if (result != ISC_R_SUCCESS) { goto cleanup; } if (client->opt != NULL) { result = dns_message_setopt(client->message, client->opt); opt_included = true; client->opt = NULL; if (result != ISC_R_SUCCESS) { goto cleanup; } } result = dns_message_rendersection(client->message, DNS_SECTION_QUESTION, 0); if (result == ISC_R_NOSPACE) { client->message->flags |= DNS_MESSAGEFLAG_TC; goto renderend; } if (result != ISC_R_SUCCESS) { goto cleanup; } /* * Stop after the question if TC was set for rate limiting. */ if ((client->message->flags & DNS_MESSAGEFLAG_TC) != 0) { goto renderend; } result = dns_message_rendersection(client->message, DNS_SECTION_ANSWER, DNS_MESSAGERENDER_PARTIAL | render_opts); if (result == ISC_R_NOSPACE) { client->message->flags |= DNS_MESSAGEFLAG_TC; goto renderend; } if (result != ISC_R_SUCCESS) { goto cleanup; } result = dns_message_rendersection( client->message, DNS_SECTION_AUTHORITY, DNS_MESSAGERENDER_PARTIAL | render_opts); if (result == ISC_R_NOSPACE) { client->message->flags |= DNS_MESSAGEFLAG_TC; goto renderend; } if (result != ISC_R_SUCCESS) { goto cleanup; } result = dns_message_rendersection(client->message, DNS_SECTION_ADDITIONAL, preferred_glue | render_opts); if (result != ISC_R_SUCCESS && result != ISC_R_NOSPACE) { goto cleanup; } renderend: result = dns_message_renderend(client->message); if (result != ISC_R_SUCCESS) { goto cleanup; } #ifdef HAVE_DNSTAP memset(&zr, 0, sizeof(zr)); if (((client->message->flags & DNS_MESSAGEFLAG_AA) != 0) && (client->query.authzone != NULL)) { isc_result_t eresult; isc_buffer_t b; dns_name_t *zo = dns_zone_getorigin(client->query.authzone); isc_buffer_init(&b, zone, sizeof(zone)); dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE); eresult = dns_name_towire(zo, &cctx, &b); if (eresult == ISC_R_SUCCESS) { isc_buffer_usedregion(&b, &zr); } } if (client->message->opcode == dns_opcode_update) { dtmsgtype = DNS_DTTYPE_UR; } else if ((client->message->flags & DNS_MESSAGEFLAG_RD) != 0) { dtmsgtype = DNS_DTTYPE_CR; } else { dtmsgtype = DNS_DTTYPE_AR; } #endif /* HAVE_DNSTAP */ if (cleanup_cctx) { dns_compress_invalidate(&cctx); } if (client->sendcb != NULL) { client->sendcb(&buffer); } else if (TCP_CLIENT(client)) { isc_buffer_usedregion(&buffer, &r); #ifdef HAVE_DNSTAP if (client->view != NULL) { dns_dt_send(client->view, dtmsgtype, &client->peeraddr, &client->destsockaddr, true, &zr, &client->requesttime, NULL, &buffer); } #endif /* HAVE_DNSTAP */ respsize = isc_buffer_usedlength(&buffer); client_sendpkg(client, &buffer); switch (isc_sockaddr_pf(&client->peeraddr)) { case AF_INET: isc_stats_increment(client->sctx->tcpoutstats4, ISC_MIN((int)respsize / 16, 256)); break; case AF_INET6: isc_stats_increment(client->sctx->tcpoutstats6, ISC_MIN((int)respsize / 16, 256)); break; default: INSIST(0); ISC_UNREACHABLE(); } } else { #ifdef HAVE_DNSTAP /* * Log dnstap data first, because client_sendpkg() may * leave client->view set to NULL. */ if (client->view != NULL) { dns_dt_send(client->view, dtmsgtype, &client->peeraddr, &client->destsockaddr, false, &zr, &client->requesttime, NULL, &buffer); } #endif /* HAVE_DNSTAP */ respsize = isc_buffer_usedlength(&buffer); client_sendpkg(client, &buffer); switch (isc_sockaddr_pf(&client->peeraddr)) { case AF_INET: isc_stats_increment(client->sctx->udpoutstats4, ISC_MIN((int)respsize / 16, 256)); break; case AF_INET6: isc_stats_increment(client->sctx->udpoutstats6, ISC_MIN((int)respsize / 16, 256)); break; default: INSIST(0); ISC_UNREACHABLE(); } } /* update statistics (XXXJT: is it okay to access message->xxxkey?) */ ns_stats_increment(client->sctx->nsstats, ns_statscounter_response); dns_rcodestats_increment(client->sctx->rcodestats, client->message->rcode); if (opt_included) { ns_stats_increment(client->sctx->nsstats, ns_statscounter_edns0out); } if (client->message->tsigkey != NULL) { ns_stats_increment(client->sctx->nsstats, ns_statscounter_tsigout); } if (client->message->sig0key != NULL) { ns_stats_increment(client->sctx->nsstats, ns_statscounter_sig0out); } if ((client->message->flags & DNS_MESSAGEFLAG_TC) != 0) { ns_stats_increment(client->sctx->nsstats, ns_statscounter_truncatedresp); } client->query.attributes |= NS_QUERYATTR_ANSWERED; return; cleanup: if (client->tcpbuf != NULL) { isc_mem_put(client->mctx, client->tcpbuf, NS_CLIENT_TCP_BUFFER_SIZE); client->tcpbuf = NULL; } if (cleanup_cctx) { dns_compress_invalidate(&cctx); } }
0
[ "CWE-617" ]
bind9
15996f0cb15631b95a801e3e88928494a69ad6ee
157,353,110,350,932,630,000,000,000,000,000,000,000
288
ns_client_error() could assert if rcode was overridden to NOERROR The client->rcode_override was originally created to force the server to send SERVFAIL in some cases when it would normally have sent FORMERR. More recently, it was used in a3ba95116ed04594ea59a8124bf781b30367a7a2 commit (part of GL #2790) to force the sending of a TC=1 NOERROR response, triggering a retry via TCP, when a UDP packet could not be sent due to ISC_R_MAXSIZE. This ran afoul of a pre-existing INSIST in ns_client_error() when RRL was in use. the INSIST was based on the assumption that ns_client_error() could never result in a non-error rcode. as that assumption is no longer valid, the INSIST has been removed.
bool is_preparing_to_stop() const { return state == PREPARING_TO_STOP; }
0
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
91,800,693,872,781,270,000,000,000,000,000,000,000
3
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
ofputil_pull_ofp15_group_mod(struct ofpbuf *msg, enum ofp_version ofp_version, struct ofputil_group_mod *gm) { const struct ofp15_group_mod *ogm; uint16_t bucket_list_len; enum ofperr error = OFPERR_OFPGMFC_BAD_BUCKET; ogm = ofpbuf_pull(msg, sizeof *ogm); gm->command = ntohs(ogm->command); gm->type = ogm->type; gm->group_id = ntohl(ogm->group_id); gm->command_bucket_id = ntohl(ogm->command_bucket_id); switch (gm->command) { case OFPGC15_REMOVE_BUCKET: if (gm->command_bucket_id == OFPG15_BUCKET_ALL) { error = 0; } /* Fall through */ case OFPGC15_INSERT_BUCKET: if (gm->command_bucket_id <= OFPG15_BUCKET_MAX || gm->command_bucket_id == OFPG15_BUCKET_FIRST || gm->command_bucket_id == OFPG15_BUCKET_LAST) { error = 0; } break; case OFPGC11_ADD: case OFPGC11_MODIFY: case OFPGC11_ADD_OR_MOD: case OFPGC11_DELETE: default: if (gm->command_bucket_id == OFPG15_BUCKET_ALL) { error = 0; } break; } if (error) { VLOG_WARN_RL(&bad_ofmsg_rl, "group command bucket id (%u) is out of range", gm->command_bucket_id); return OFPERR_OFPGMFC_BAD_BUCKET; } bucket_list_len = ntohs(ogm->bucket_array_len); if (bucket_list_len > msg->size) { return OFPERR_OFPBRC_BAD_LEN; } error = ofputil_pull_ofp15_buckets(msg, bucket_list_len, ofp_version, gm->type, &gm->buckets); if (error) { return error; } return parse_ofp15_group_properties(msg, gm->type, gm->command, &gm->props, msg->size); }
1
[ "CWE-772" ]
ovs
f673f4059717dc9d2d6dd2d4db52be1149a996dd
75,033,925,966,238,920,000,000,000,000,000,000,000
57
ofp-util: Fix memory leaks when parsing OF1.5 group properties. Found by libFuzzer. Reported-by: Bhargava Shastry <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Justin Pettit <[email protected]>
mkstemp_helper (struct obstack *obs, const char *name) { int fd; int len; int i; /* Guarantee that there are six trailing 'X' characters, even if the user forgot to supply them. */ len = strlen (name); obstack_grow (obs, name, len); for (i = 0; len > 0 && i < 6; i++) if (name[--len] != 'X') break; for (; i < 6; i++) obstack_1grow (obs, 'X'); obstack_1grow (obs, '\0'); errno = 0; fd = mkstemp ((char *) obstack_base (obs)); if (fd < 0) { M4ERROR ((0, errno, "cannot create tempfile `%s'", name)); obstack_free (obs, obstack_finish (obs)); } else close (fd); }
1
[]
m4
5345bb49077bfda9fabd048e563f9e7077fe335d
323,725,070,097,395,600,000,000,000,000,000,000,000
27
Minor security fix: Quote output of mkstemp. * src/builtin.c (mkstemp_helper): Produce quoted output. * doc/m4.texinfo (Mkstemp): Update the documentation and tests. * NEWS: Document this change. Signed-off-by: Eric Blake <[email protected]> (cherry picked from commit bd9900d65eb9cd5add0f107e94b513fa267495ba)
CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, const char *pinnedpubkey, const unsigned char *pubkey, size_t pubkeylen) { FILE *fp; unsigned char *buf = NULL, *pem_ptr = NULL; CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH; /* if a path wasn't specified, don't pin */ if(!pinnedpubkey) return CURLE_OK; if(!pubkey || !pubkeylen) return result; /* only do this if pinnedpubkey starts with "sha256//", length 8 */ if(strncmp(pinnedpubkey, "sha256//", 8) == 0) { CURLcode encode; size_t encodedlen, pinkeylen; char *encoded, *pinkeycopy, *begin_pos, *end_pos; unsigned char *sha256sumdigest; if(!Curl_ssl->sha256sum) { /* without sha256 support, this cannot match */ return result; } /* compute sha256sum of public key */ sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH); if(!sha256sumdigest) return CURLE_OUT_OF_MEMORY; encode = Curl_ssl->sha256sum(pubkey, pubkeylen, sha256sumdigest, CURL_SHA256_DIGEST_LENGTH); if(encode != CURLE_OK) return encode; encode = Curl_base64_encode((char *)sha256sumdigest, CURL_SHA256_DIGEST_LENGTH, &encoded, &encodedlen); Curl_safefree(sha256sumdigest); if(encode) return encode; infof(data, " public key hash: sha256//%s", encoded); /* it starts with sha256//, copy so we can modify it */ pinkeylen = strlen(pinnedpubkey) + 1; pinkeycopy = malloc(pinkeylen); if(!pinkeycopy) { Curl_safefree(encoded); return CURLE_OUT_OF_MEMORY; } memcpy(pinkeycopy, pinnedpubkey, pinkeylen); /* point begin_pos to the copy, and start extracting keys */ begin_pos = pinkeycopy; do { end_pos = strstr(begin_pos, ";sha256//"); /* * if there is an end_pos, null terminate, * otherwise it'll go to the end of the original string */ if(end_pos) end_pos[0] = '\0'; /* compare base64 sha256 digests, 8 is the length of "sha256//" */ if(encodedlen == strlen(begin_pos + 8) && !memcmp(encoded, begin_pos + 8, encodedlen)) { result = CURLE_OK; break; } /* * change back the null-terminator we changed earlier, * and look for next begin */ if(end_pos) { end_pos[0] = ';'; begin_pos = strstr(end_pos, "sha256//"); } } while(end_pos && begin_pos); Curl_safefree(encoded); Curl_safefree(pinkeycopy); return result; } fp = fopen(pinnedpubkey, "rb"); if(!fp) return result; do { long filesize; size_t size, pem_len; CURLcode pem_read; /* Determine the file's size */ if(fseek(fp, 0, SEEK_END)) break; filesize = ftell(fp); if(fseek(fp, 0, SEEK_SET)) break; if(filesize < 0 || filesize > MAX_PINNED_PUBKEY_SIZE) break; /* * if the size of our certificate is bigger than the file * size then it can't match */ size = curlx_sotouz((curl_off_t) filesize); if(pubkeylen > size) break; /* * Allocate buffer for the pinned key * With 1 additional byte for null terminator in case of PEM key */ buf = malloc(size + 1); if(!buf) break; /* Returns number of elements read, which should be 1 */ if((int) fread(buf, size, 1, fp) != 1) break; /* If the sizes are the same, it can't be base64 encoded, must be der */ if(pubkeylen == size) { if(!memcmp(pubkey, buf, pubkeylen)) result = CURLE_OK; break; } /* * Otherwise we will assume it's PEM and try to decode it * after placing null terminator */ buf[size] = '\0'; pem_read = pubkey_pem_to_der((const char *)buf, &pem_ptr, &pem_len); /* if it wasn't read successfully, exit */ if(pem_read) break; /* * if the size of our certificate doesn't match the size of * the decoded file, they can't be the same, otherwise compare */ if(pubkeylen == pem_len && !memcmp(pubkey, pem_ptr, pubkeylen)) result = CURLE_OK; } while(0); Curl_safefree(buf); Curl_safefree(pem_ptr); fclose(fp); return result; }
0
[]
curl
852aa5ad351ea53e5f01d2f44b5b4370c2bf5425
232,380,759,626,296,400,000,000,000,000,000,000,000
155
url: check sasl additional parameters for connection reuse. Also move static function safecmp() as non-static Curl_safecmp() since its purpose is needed at several places. Bug: https://curl.se/docs/CVE-2022-22576.html CVE-2022-22576 Closes #8746
MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, const FilterType filter,const MagickBooleanType cylindrical, ExceptionInfo *exception) { const char *artifact; FilterType filter_type, window_type; double B, C, value; register ResizeFilter *resize_filter; /* Table Mapping given Filter, into Weighting and Windowing functions. A 'Box' windowing function means its a simble non-windowed filter. An 'SincFast' filter function could be upgraded to a 'Jinc' filter if a "cylindrical" is requested, unless a 'Sinc' or 'SincFast' filter was specifically requested by the user. WARNING: The order of this table must match the order of the FilterType enumeration specified in "resample.h", or the filter names will not match the filter being setup. You can check filter setups with the "filter:verbose" expert setting. */ static struct { FilterType filter, window; } const mapping[SentinelFilter] = { { UndefinedFilter, BoxFilter }, /* Undefined (default to Box) */ { PointFilter, BoxFilter }, /* SPECIAL: Nearest neighbour */ { BoxFilter, BoxFilter }, /* Box averaging filter */ { TriangleFilter, BoxFilter }, /* Linear interpolation filter */ { HermiteFilter, BoxFilter }, /* Hermite interpolation filter */ { SincFastFilter, HannFilter }, /* Hann -- cosine-sinc */ { SincFastFilter, HammingFilter }, /* Hamming -- '' variation */ { SincFastFilter, BlackmanFilter }, /* Blackman -- 2*cosine-sinc */ { GaussianFilter, BoxFilter }, /* Gaussian blur filter */ { QuadraticFilter, BoxFilter }, /* Quadratic Gaussian approx */ { CubicFilter, BoxFilter }, /* General Cubic Filter, Spline */ { CatromFilter, BoxFilter }, /* Cubic-Keys interpolator */ { MitchellFilter, BoxFilter }, /* 'Ideal' Cubic-Keys filter */ { JincFilter, BoxFilter }, /* Raw 3-lobed Jinc function */ { SincFilter, BoxFilter }, /* Raw 4-lobed Sinc function */ { SincFastFilter, BoxFilter }, /* Raw fast sinc ("Pade"-type) */ { SincFastFilter, KaiserFilter }, /* Kaiser -- square root-sinc */ { LanczosFilter, WelchFilter }, /* Welch -- parabolic (3 lobe) */ { SincFastFilter, CubicFilter }, /* Parzen -- cubic-sinc */ { SincFastFilter, BohmanFilter }, /* Bohman -- 2*cosine-sinc */ { SincFastFilter, TriangleFilter }, /* Bartlett -- triangle-sinc */ { LagrangeFilter, BoxFilter }, /* Lagrange self-windowing */ { LanczosFilter, LanczosFilter }, /* Lanczos Sinc-Sinc filters */ { LanczosSharpFilter, LanczosSharpFilter }, /* | these require */ { Lanczos2Filter, Lanczos2Filter }, /* | special handling */ { Lanczos2SharpFilter, Lanczos2SharpFilter }, { RobidouxFilter, BoxFilter }, /* Cubic Keys tuned for EWA */ { RobidouxSharpFilter, BoxFilter }, /* Sharper Cubic Keys for EWA */ { LanczosFilter, CosineFilter }, /* Cosine window (3 lobes) */ { SplineFilter, BoxFilter }, /* Spline Cubic Filter */ { LanczosRadiusFilter, LanczosFilter }, /* Lanczos with integer radius */ { CubicSplineFilter, BoxFilter }, /* CubicSpline (2/3/4 lobes) */ }; /* Table mapping the filter/window from the above table to an actual function. The default support size for that filter as a weighting function, the range to scale with to use that function as a sinc windowing function, (typ 1.0). Note that the filter_type -> function is 1 to 1 except for Sinc(), SincFast(), and CubicBC() functions, which may have multiple filter to function associations. See "filter:verbose" handling below for the function -> filter mapping. */ static struct { double (*function)(const double,const ResizeFilter*), support, /* Default lobes/support size of the weighting filter. */ scale, /* Support when function used as a windowing function Typically equal to the location of the first zero crossing. */ B,C; /* BC-spline coefficients, ignored if not a CubicBC filter. */ ResizeWeightingFunctionType weightingFunctionType; } const filters[SentinelFilter] = { /* .--- support window (if used as a Weighting Function) | .--- first crossing (if used as a Windowing Function) | | .--- B value for Cubic Function | | | .---- C value for Cubic Function | | | | */ { Box, 0.5, 0.5, 0.0, 0.0, BoxWeightingFunction }, /* Undefined (default to Box) */ { Box, 0.0, 0.5, 0.0, 0.0, BoxWeightingFunction }, /* Point (special handling) */ { Box, 0.5, 0.5, 0.0, 0.0, BoxWeightingFunction }, /* Box */ { Triangle, 1.0, 1.0, 0.0, 0.0, TriangleWeightingFunction }, /* Triangle */ { CubicBC, 1.0, 1.0, 0.0, 0.0, CubicBCWeightingFunction }, /* Hermite (cubic B=C=0) */ { Hann, 1.0, 1.0, 0.0, 0.0, HannWeightingFunction }, /* Hann, cosine window */ { Hamming, 1.0, 1.0, 0.0, 0.0, HammingWeightingFunction }, /* Hamming, '' variation */ { Blackman, 1.0, 1.0, 0.0, 0.0, BlackmanWeightingFunction }, /* Blackman, 2*cosine window */ { Gaussian, 2.0, 1.5, 0.0, 0.0, GaussianWeightingFunction }, /* Gaussian */ { Quadratic, 1.5, 1.5, 0.0, 0.0, QuadraticWeightingFunction },/* Quadratic gaussian */ { CubicBC, 2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* General Cubic Filter */ { CubicBC, 2.0, 1.0, 0.0, 0.5, CubicBCWeightingFunction }, /* Catmull-Rom (B=0,C=1/2) */ { CubicBC, 2.0, 8.0/7.0, 1./3., 1./3., CubicBCWeightingFunction }, /* Mitchell (B=C=1/3) */ { Jinc, 3.0, 1.2196698912665045, 0.0, 0.0, JincWeightingFunction }, /* Raw 3-lobed Jinc */ { Sinc, 4.0, 1.0, 0.0, 0.0, SincWeightingFunction }, /* Raw 4-lobed Sinc */ { SincFast, 4.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Raw fast sinc ("Pade"-type) */ { Kaiser, 1.0, 1.0, 0.0, 0.0, KaiserWeightingFunction }, /* Kaiser (square root window) */ { Welch, 1.0, 1.0, 0.0, 0.0, WelchWeightingFunction }, /* Welch (parabolic window) */ { CubicBC, 2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Parzen (B-Spline window) */ { Bohman, 1.0, 1.0, 0.0, 0.0, BohmanWeightingFunction }, /* Bohman, 2*Cosine window */ { Triangle, 1.0, 1.0, 0.0, 0.0, TriangleWeightingFunction }, /* Bartlett (triangle window) */ { Lagrange, 2.0, 1.0, 0.0, 0.0, LagrangeWeightingFunction }, /* Lagrange sinc approximation */ { SincFast, 3.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, 3-lobed Sinc-Sinc */ { SincFast, 3.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, Sharpened */ { SincFast, 2.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, 2-lobed */ { SincFast, 2.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos2, sharpened */ /* Robidoux: Keys cubic close to Lanczos2D sharpened */ { CubicBC, 2.0, 1.1685777620836932, 0.37821575509399867, 0.31089212245300067, CubicBCWeightingFunction }, /* RobidouxSharp: Sharper version of Robidoux */ { CubicBC, 2.0, 1.105822933719019, 0.2620145123990142, 0.3689927438004929, CubicBCWeightingFunction }, { Cosine, 1.0, 1.0, 0.0, 0.0, CosineWeightingFunction }, /* Low level cosine window */ { CubicBC, 2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction }, /* Cubic B-Spline (B=1,C=0) */ { SincFast, 3.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, Interger Radius */ { CubicSpline,2.0, 0.5, 0.0, 0.0, BoxWeightingFunction }, /* Spline Lobes 2-lobed */ }; /* The known zero crossings of the Jinc() or more accurately the Jinc(x*PI) function being used as a filter. It is used by the "filter:lobes" expert setting and for 'lobes' for Jinc functions in the previous table. This way users do not have to deal with the highly irrational lobe sizes of the Jinc filter. Values taken from http://cose.math.bas.bg/webMathematica/webComputing/BesselZeros.jsp using Jv-function with v=1, then dividing by PI. */ static double jinc_zeros[16] = { 1.2196698912665045, 2.2331305943815286, 3.2383154841662362, 4.2410628637960699, 5.2427643768701817, 6.2439216898644877, 7.2447598687199570, 8.2453949139520427, 9.2458926849494673, 10.246293348754916, 11.246622794877883, 12.246898461138105, 13.247132522181061, 14.247333735806849, 15.247508563037300, 16.247661874700962 }; /* Allocate resize filter. */ assert(image != (const Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(UndefinedFilter < filter && filter < SentinelFilter); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); (void) exception; resize_filter=(ResizeFilter *) AcquireCriticalMemory(sizeof(*resize_filter)); (void) memset(resize_filter,0,sizeof(*resize_filter)); /* Defaults for the requested filter. */ filter_type=mapping[filter].filter; window_type=mapping[filter].window; resize_filter->blur=1.0; /* Promote 1D Windowed Sinc Filters to a 2D Windowed Jinc filters */ if ((cylindrical != MagickFalse) && (filter_type == SincFastFilter) && (filter != SincFastFilter)) filter_type=JincFilter; /* 1D Windowed Sinc => 2D Windowed Jinc filters */ /* Expert filter setting override */ artifact=GetImageArtifact(image,"filter:filter"); if (IsStringTrue(artifact) != MagickFalse) { ssize_t option; option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact); if ((UndefinedFilter < option) && (option < SentinelFilter)) { /* Raw filter request - no window function. */ filter_type=(FilterType) option; window_type=BoxFilter; } /* Filter override with a specific window function. */ artifact=GetImageArtifact(image,"filter:window"); if (artifact != (const char *) NULL) { option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact); if ((UndefinedFilter < option) && (option < SentinelFilter)) window_type=(FilterType) option; } } else { /* Window specified, but no filter function? Assume Sinc/Jinc. */ artifact=GetImageArtifact(image,"filter:window"); if (artifact != (const char *) NULL) { ssize_t option; option=ParseCommandOption(MagickFilterOptions,MagickFalse,artifact); if ((UndefinedFilter < option) && (option < SentinelFilter)) { filter_type= cylindrical != MagickFalse ? JincFilter : SincFastFilter; window_type=(FilterType) option; } } } /* Assign the real functions to use for the filters selected. */ resize_filter->filter=filters[filter_type].function; resize_filter->support=filters[filter_type].support; resize_filter->filterWeightingType=filters[filter_type].weightingFunctionType; resize_filter->window=filters[window_type].function; resize_filter->windowWeightingType=filters[window_type].weightingFunctionType; resize_filter->scale=filters[window_type].scale; resize_filter->signature=MagickCoreSignature; /* Filter Modifications for orthogonal/cylindrical usage */ if (cylindrical != MagickFalse) switch (filter_type) { case BoxFilter: /* Support for Cylindrical Box should be sqrt(2)/2 */ resize_filter->support=(double) MagickSQ1_2; break; case LanczosFilter: case LanczosSharpFilter: case Lanczos2Filter: case Lanczos2SharpFilter: case LanczosRadiusFilter: resize_filter->filter=filters[JincFilter].function; resize_filter->window=filters[JincFilter].function; resize_filter->scale=filters[JincFilter].scale; /* number of lobes (support window size) remain unchanged */ break; default: break; } /* Global Sharpening (regardless of orthoginal/cylindrical) */ switch (filter_type) { case LanczosSharpFilter: resize_filter->blur *= 0.9812505644269356; break; case Lanczos2SharpFilter: resize_filter->blur *= 0.9549963639785485; break; /* case LanczosRadius: blur adjust is done after lobes */ default: break; } /* Expert Option Modifications. */ /* User Gaussian Sigma Override - no support change */ if ((resize_filter->filter == Gaussian) || (resize_filter->window == Gaussian) ) { value=0.5; /* guassian sigma default, half pixel */ artifact=GetImageArtifact(image,"filter:sigma"); if (artifact != (const char *) NULL) value=StringToDouble(artifact,(char **) NULL); /* Define coefficents for Gaussian */ resize_filter->coefficient[0]=value; /* note sigma too */ resize_filter->coefficient[1]=PerceptibleReciprocal(2.0*value*value); /* sigma scaling */ resize_filter->coefficient[2]=PerceptibleReciprocal(Magick2PI*value*value); /* normalization - not actually needed or used! */ if ( value > 0.5 ) resize_filter->support *= 2*value; /* increase support linearly */ } /* User Kaiser Alpha Override - no support change */ if ((resize_filter->filter == Kaiser) || (resize_filter->window == Kaiser) ) { value=6.5; /* default beta value for Kaiser bessel windowing function */ artifact=GetImageArtifact(image,"filter:alpha"); /* FUTURE: depreciate */ if (artifact != (const char *) NULL) value=StringToDouble(artifact,(char **) NULL); artifact=GetImageArtifact(image,"filter:kaiser-beta"); if (artifact != (const char *) NULL) value=StringToDouble(artifact,(char **) NULL); artifact=GetImageArtifact(image,"filter:kaiser-alpha"); if (artifact != (const char *) NULL) value=StringToDouble(artifact,(char **) NULL)*MagickPI; /* Define coefficents for Kaiser Windowing Function */ resize_filter->coefficient[0]=value; /* alpha */ resize_filter->coefficient[1]=PerceptibleReciprocal(I0(value)); /* normalization */ } /* Support Overrides */ artifact=GetImageArtifact(image,"filter:lobes"); if (artifact != (const char *) NULL) { ssize_t lobes; lobes=(ssize_t) StringToLong(artifact); if (lobes < 1) lobes=1; resize_filter->support=(double) lobes; } if (resize_filter->filter == Jinc) { /* Convert a Jinc function lobes value to a real support value. */ if (resize_filter->support > 16) resize_filter->support=jinc_zeros[15]; /* largest entry in table */ else resize_filter->support=jinc_zeros[((long) resize_filter->support)-1]; /* Blur this filter so support is a integer value (lobes dependant). */ if (filter_type == LanczosRadiusFilter) resize_filter->blur*=floor(resize_filter->support)/ resize_filter->support; } /* Expert blur override. */ artifact=GetImageArtifact(image,"filter:blur"); if (artifact != (const char *) NULL) resize_filter->blur*=StringToDouble(artifact,(char **) NULL); if (resize_filter->blur < MagickEpsilon) resize_filter->blur=(double) MagickEpsilon; /* Expert override of the support setting. */ artifact=GetImageArtifact(image,"filter:support"); if (artifact != (const char *) NULL) resize_filter->support=fabs(StringToDouble(artifact,(char **) NULL)); /* Scale windowing function separately to the support 'clipping' window that calling operator is planning to actually use. (Expert override) */ resize_filter->window_support=resize_filter->support; /* default */ artifact=GetImageArtifact(image,"filter:win-support"); if (artifact != (const char *) NULL) resize_filter->window_support=fabs(StringToDouble(artifact,(char **) NULL)); /* Adjust window function scaling to match windowing support for weighting function. This avoids a division on every filter call. */ resize_filter->scale/=resize_filter->window_support; /* * Set Cubic Spline B,C values, calculate Cubic coefficients. */ B=0.0; C=0.0; if ((resize_filter->filter == CubicBC) || (resize_filter->window == CubicBC) ) { B=filters[filter_type].B; C=filters[filter_type].C; if (filters[window_type].function == CubicBC) { B=filters[window_type].B; C=filters[window_type].C; } artifact=GetImageArtifact(image,"filter:b"); if (artifact != (const char *) NULL) { B=StringToDouble(artifact,(char **) NULL); C=(1.0-B)/2.0; /* Calculate C to get a Keys cubic filter. */ artifact=GetImageArtifact(image,"filter:c"); /* user C override */ if (artifact != (const char *) NULL) C=StringToDouble(artifact,(char **) NULL); } else { artifact=GetImageArtifact(image,"filter:c"); if (artifact != (const char *) NULL) { C=StringToDouble(artifact,(char **) NULL); B=1.0-2.0*C; /* Calculate B to get a Keys cubic filter. */ } } { const double twoB = B+B; /* Convert B,C values into Cubic Coefficents. See CubicBC(). */ resize_filter->coefficient[0]=1.0-(1.0/3.0)*B; resize_filter->coefficient[1]=-3.0+twoB+C; resize_filter->coefficient[2]=2.0-1.5*B-C; resize_filter->coefficient[3]=(4.0/3.0)*B+4.0*C; resize_filter->coefficient[4]=-8.0*C-twoB; resize_filter->coefficient[5]=B+5.0*C; resize_filter->coefficient[6]=(-1.0/6.0)*B-C; } } /* Expert Option Request for verbose details of the resulting filter. */ #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp master { #endif if (IsStringTrue(GetImageArtifact(image,"filter:verbose")) != MagickFalse) { double support, x; /* Set the weighting function properly when the weighting function may not exactly match the filter of the same name. EG: a Point filter is really uses a Box weighting function with a different support than is typically used. */ if (resize_filter->filter == Box) filter_type=BoxFilter; if (resize_filter->filter == Sinc) filter_type=SincFilter; if (resize_filter->filter == SincFast) filter_type=SincFastFilter; if (resize_filter->filter == Jinc) filter_type=JincFilter; if (resize_filter->filter == CubicBC) filter_type=CubicFilter; if (resize_filter->window == Box) window_type=BoxFilter; if (resize_filter->window == Sinc) window_type=SincFilter; if (resize_filter->window == SincFast) window_type=SincFastFilter; if (resize_filter->window == Jinc) window_type=JincFilter; if (resize_filter->window == CubicBC) window_type=CubicFilter; /* Report Filter Details. */ support=GetResizeFilterSupport(resize_filter); /* practical_support */ (void) FormatLocaleFile(stdout, "# Resampling Filter (for graphing)\n#\n"); (void) FormatLocaleFile(stdout,"# filter = %s\n", CommandOptionToMnemonic(MagickFilterOptions,filter_type)); (void) FormatLocaleFile(stdout,"# window = %s\n", CommandOptionToMnemonic(MagickFilterOptions,window_type)); (void) FormatLocaleFile(stdout,"# support = %.*g\n", GetMagickPrecision(),(double) resize_filter->support); (void) FormatLocaleFile(stdout,"# window-support = %.*g\n", GetMagickPrecision(),(double) resize_filter->window_support); (void) FormatLocaleFile(stdout,"# scale-blur = %.*g\n", GetMagickPrecision(),(double) resize_filter->blur); if ((filter_type == GaussianFilter) || (window_type == GaussianFilter)) (void) FormatLocaleFile(stdout,"# gaussian-sigma = %.*g\n", GetMagickPrecision(),(double) resize_filter->coefficient[0]); if ( filter_type == KaiserFilter || window_type == KaiserFilter ) (void) FormatLocaleFile(stdout,"# kaiser-beta = %.*g\n", GetMagickPrecision(),(double) resize_filter->coefficient[0]); (void) FormatLocaleFile(stdout,"# practical-support = %.*g\n", GetMagickPrecision(), (double) support); if ((filter_type == CubicFilter) || (window_type == CubicFilter)) (void) FormatLocaleFile(stdout,"# B,C = %.*g,%.*g\n", GetMagickPrecision(),(double) B,GetMagickPrecision(),(double) C); (void) FormatLocaleFile(stdout,"\n"); /* Output values of resulting filter graph -- for graphing filter result. */ for (x=0.0; x <= support; x+=0.01f) (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",x, GetMagickPrecision(),(double) GetResizeFilterWeight(resize_filter,x)); /* A final value so gnuplot can graph the 'stop' properly. */ (void) FormatLocaleFile(stdout,"%5.2lf\t%.*g\n",support, GetMagickPrecision(),0.0); } /* Output the above once only for each image - remove setting */ (void) DeleteImageArtifact((Image *) image,"filter:verbose"); #if defined(MAGICKCORE_OPENMP_SUPPORT) } #endif return(resize_filter); }
1
[ "CWE-369" ]
ImageMagick
43539e67a47d2f8de832d33a5b26dc2a7a12294f
52,151,043,543,467,730,000,000,000,000,000,000,000
498
https://github.com/ImageMagick/ImageMagick/issues/1718
optimize_straight_join(JOIN *join, table_map join_tables) { JOIN_TAB *s; uint idx= join->const_tables; bool disable_jbuf= join->thd->variables.join_cache_level == 0; double record_count= 1.0; double read_time= 0.0; uint use_cond_selectivity= join->thd->variables.optimizer_use_condition_selectivity; POSITION loose_scan_pos; THD *thd= join->thd; for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++) { POSITION *position= join->positions + idx; Json_writer_object trace_one_table(thd); if (unlikely(thd->trace_started())) { trace_plan_prefix(join, idx, join_tables); trace_one_table.add_table_name(s); } /* Find the best access method from 's' to the current partial plan */ best_access_path(join, s, join_tables, join->positions, idx, disable_jbuf, record_count, position, &loose_scan_pos); /* compute the cost of the new plan extended with 's' */ record_count= COST_MULT(record_count, position->records_read); const double filter_cmp_gain= position->range_rowid_filter_info ? position->range_rowid_filter_info->get_cmp_gain(record_count) : 0; read_time+= COST_ADD(read_time - filter_cmp_gain, COST_ADD(position->read_time, record_count / (double) TIME_FOR_COMPARE)); advance_sj_state(join, join_tables, idx, &record_count, &read_time, &loose_scan_pos); join_tables&= ~(s->table->map); double pushdown_cond_selectivity= 1.0; if (use_cond_selectivity > 1) pushdown_cond_selectivity= table_cond_selectivity(join, idx, s, join_tables); position->cond_selectivity= pushdown_cond_selectivity; ++idx; } if (join->sort_by_table && join->sort_by_table != join->positions[join->const_tables].table->table) read_time+= record_count; // We have to make a temp table memcpy((uchar*) join->best_positions, (uchar*) join->positions, sizeof(POSITION)*idx); join->join_record_count= record_count; join->best_read= read_time - 0.001; }
0
[]
server
8c34eab9688b4face54f15f89f5d62bdfd93b8a7
121,259,297,233,964,330,000,000,000,000,000,000,000
54
MDEV-28094 Window function in expression in ORDER BY call item->split_sum_func() in setup_order() just as it's done in setup_fields()
FilterHeadersStatus decodeHeaders(RequestHeaderMap& headers, bool end_stream) { is_grpc_request_ = Grpc::Common::isGrpcRequestHeaders(headers); FilterHeadersStatus status = handle_->decodeHeaders(headers, end_stream); return status; }
0
[ "CWE-416" ]
envoy
148de954ed3585d8b4298b424aa24916d0de6136
299,736,870,351,311,000,000,000,000,000,000,000,000
5
CVE-2021-43825 Response filter manager crash Signed-off-by: Yan Avlasov <[email protected]>
void subselect_single_select_engine::exclude() { select_lex->master_unit()->exclude_level(); }
0
[ "CWE-89" ]
server
3c209bfc040ddfc41ece8357d772547432353fd2
298,650,488,775,161,250,000,000,000,000,000,000,000
4
MDEV-25994: Crash with union of my_decimal type in ORDER BY clause When single-row subquery fails with "Subquery reutrns more than 1 row" error, it will raise an error and return NULL. On the other hand, Item_singlerow_subselect sets item->maybe_null=0 for table-less subqueries like "(SELECT not_null_value)" (*) This discrepancy (item with maybe_null=0 returning NULL) causes the code in Type_handler_decimal_result::make_sort_key_part() to crash. Fixed this by allowing inference (*) only when the subquery is NOT a UNION.
ex_wincmd(exarg_T *eap) { int xchar = NUL; char_u *p; if (*eap->arg == 'g' || *eap->arg == Ctrl_G) { // CTRL-W g and CTRL-W CTRL-G have an extra command character if (eap->arg[1] == NUL) { emsg(_(e_invarg)); return; } xchar = eap->arg[1]; p = eap->arg + 2; } else p = eap->arg + 1; set_nextcmd(eap, p); p = skipwhite(p); if (*p != NUL && *p != ( #ifdef FEAT_EVAL in_vim9script() ? '#' : #endif '"') && eap->nextcmd == NULL) emsg(_(e_invarg)); else if (!eap->skip) { // Pass flags on for ":vertical wincmd ]". postponed_split_flags = cmdmod.cmod_split; postponed_split_tab = cmdmod.cmod_tab; do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); postponed_split_flags = 0; postponed_split_tab = 0; } }
0
[ "CWE-122" ]
vim
35a319b77f897744eec1155b736e9372c9c5575f
221,046,758,419,728,400,000,000,000,000,000,000,000
38
patch 8.2.3489: ml_get error after search with range Problem: ml_get error after search with range. Solution: Limit the line number to the buffer line count.
static NDIS_STATUS SetupDPCTarget(PARANDIS_ADAPTER *pContext) { ULONG i; #if NDIS_SUPPORT_NDIS620 NDIS_STATUS status; PROCESSOR_NUMBER procNumber; #endif for (i = 0; i < pContext->nPathBundles; i++) { #if NDIS_SUPPORT_NDIS620 status = KeGetProcessorNumberFromIndex(i, &procNumber); if (status != NDIS_STATUS_SUCCESS) { DPrintf(0, ("[%s] - KeGetProcessorNumberFromIndex failed for index %lu - %d\n", __FUNCTION__, i, status)); return status; } ParaNdis_ProcessorNumberToGroupAffinity(&pContext->pPathBundles[i].rxPath.DPCAffinity, &procNumber); pContext->pPathBundles[i].txPath.DPCAffinity = pContext->pPathBundles[i].rxPath.DPCAffinity; #elif NDIS_SUPPORT_NDIS6 pContext->pPathBundles[i].rxPath.DPCTargetProcessor = 1i64 << i; pContext->pPathBundles[i].txPath.DPCTargetProcessor = pContext->pPathBundles[i].rxPath.DPCTargetProcessor; #else #error not supported #endif } #if NDIS_SUPPORT_NDIS620 pContext->CXPath.DPCAffinity = pContext->pPathBundles[0].rxPath.DPCAffinity; #elif NDIS_SUPPORT_NDIS6 pContext->CXPath.DPCTargetProcessor = pContext->pPathBundles[0].rxPath.DPCTargetProcessor; #else #error not yet defined #endif return NDIS_STATUS_SUCCESS; }
0
[ "CWE-20" ]
kvm-guest-drivers-windows
723416fa4210b7464b28eab89cc76252e6193ac1
137,918,903,722,077,100,000,000,000,000,000,000,000
36
NetKVM: BZ#1169718: Checking the length only on read Signed-off-by: Joseph Hindin <[email protected]>
Return(expr_ty value, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { stmt_ty p; p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) return NULL; p->kind = Return_kind; p->v.Return.value = value; p->lineno = lineno; p->col_offset = col_offset; p->end_lineno = end_lineno; p->end_col_offset = end_col_offset; return p; }
0
[ "CWE-125" ]
cpython
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
142,045,185,223,296,860,000,000,000,000,000,000,000
15
bpo-35766: Merge typed_ast back into CPython (GH-11645)
void check_homedir(const char *dir) { assert(dir); if (dir[0] != '/') { fprintf(stderr, "Error: invalid user directory \"%s\"\n", dir); exit(1); } // symlinks are rejected in many places if (has_link(dir)) fmessage("No full support for symbolic links in path of user directory.\n" "Please provide resolved path in password database (/etc/passwd).\n\n"); }
0
[ "CWE-269", "CWE-94" ]
firejail
27cde3d7d1e4e16d4190932347c7151dc2a84c50
154,353,245,570,467,400,000,000,000,000,000,000,000
11
fixing CVE-2022-31214
template<typename tp, typename tt, typename tc> CImg<T>& draw_spline(const CImg<tp>& points, const CImg<tt>& tangents, const tc *const color, const float opacity=1, const bool is_closed_set=false, const float precision=4, const unsigned int pattern=~0U, const bool init_hatch=true) { if (is_empty() || !points || !tangents || points._width<2 || tangents._width<2) return *this; bool ninit_hatch = init_hatch; switch (points._height) { case 0 : case 1 : throw CImgArgumentException(_cimg_instance "draw_spline(): Invalid specified point set (%u,%u,%u,%u,%p).", cimg_instance, points._width,points._height,points._depth,points._spectrum,points._data); case 2 : { const int x0 = (int)points(0,0), y0 = (int)points(0,1); const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1); int ox = x0, oy = y0; float ou = u0, ov = v0; for (unsigned int i = 1; i<points._width; ++i) { const int x = (int)points(i,0), y = (int)points(i,1); const float u = (float)tangents(i,0), v = (float)tangents(i,1); draw_spline(ox,oy,ou,ov,x,y,u,v,color,precision,opacity,pattern,ninit_hatch); ninit_hatch = false; ox = x; oy = y; ou = u; ov = v; } if (is_closed_set) draw_spline(ox,oy,ou,ov,x0,y0,u0,v0,color,precision,opacity,pattern,false); } break; default : { const int x0 = (int)points(0,0), y0 = (int)points(0,1), z0 = (int)points(0,2); const float u0 = (float)tangents(0,0), v0 = (float)tangents(0,1), w0 = (float)tangents(0,2); int ox = x0, oy = y0, oz = z0; float ou = u0, ov = v0, ow = w0; for (unsigned int i = 1; i<points._width; ++i) { const int x = (int)points(i,0), y = (int)points(i,1), z = (int)points(i,2); const float u = (float)tangents(i,0), v = (float)tangents(i,1), w = (float)tangents(i,2); draw_spline(ox,oy,oz,ou,ov,ow,x,y,z,u,v,w,color,opacity,pattern,ninit_hatch); ninit_hatch = false; ox = x; oy = y; oz = z; ou = u; ov = v; ow = w; } if (is_closed_set) draw_spline(ox,oy,oz,ou,ov,ow,x0,y0,z0,u0,v0,w0,color,precision,opacity,pattern,false); } } return *this;
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
62,009,108,135,594,110,000,000,000,000,000,000,000
44
Fix other issues in 'CImg<T>::load_bmp()'.
static int handle_external_interrupt(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { ++vcpu->stat.irq_exits; KVMTRACE_1D(INTR, vcpu, vmcs_read32(VM_EXIT_INTR_INFO), handler); return 1; }
0
[ "CWE-20" ]
linux-2.6
16175a796d061833aacfbd9672235f2d2725df65
291,801,139,805,905,700,000,000,000,000,000,000,000
7
KVM: VMX: Don't allow uninhibited access to EFER on i386 vmx_set_msr() does not allow i386 guests to touch EFER, but they can still do so through the default: label in the switch. If they set EFER_LME, they can oops the host. Fix by having EFER access through the normal channel (which will check for EFER_LME) even on i386. Reported-and-tested-by: Benjamin Gilbert <[email protected]> Cc: [email protected] Signed-off-by: Avi Kivity <[email protected]>
int page_symlink(struct inode *inode, const char *symname, int len) { return __page_symlink(inode, symname, len, !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS)); }
0
[ "CWE-20", "CWE-362", "CWE-416" ]
linux
86acdca1b63e6890540fa19495cfc708beff3d8b
161,856,207,755,936,060,000,000,000,000,000,000,000
5
fix autofs/afs/etc. magic mountpoint breakage We end up trying to kfree() nd.last.name on open("/mnt/tmp", O_CREAT) if /mnt/tmp is an autofs direct mount. The reason is that nd.last_type is bogus here; we want LAST_BIND for everything of that kind and we get LAST_NORM left over from finding parent directory. So make sure that it *is* set properly; set to LAST_BIND before doing ->follow_link() - for normal symlinks it will be changed by __vfs_follow_link() and everything else needs it set that way. Signed-off-by: Al Viro <[email protected]>
__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, int len, __wsum csum) { int start = skb_headlen(skb); int i, copy = start - offset; struct sk_buff *frag_iter; int pos = 0; /* Copy header. */ if (copy > 0) { if (copy > len) copy = len; csum = csum_partial_copy_nocheck(skb->data + offset, to, copy, csum); if ((len -= copy) == 0) return csum; offset += copy; to += copy; pos = copy; } for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { int end; WARN_ON(start > offset + len); end = start + skb_frag_size(&skb_shinfo(skb)->frags[i]); if ((copy = end - offset) > 0) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; u32 p_off, p_len, copied; struct page *p; __wsum csum2; u8 *vaddr; if (copy > len) copy = len; skb_frag_foreach_page(frag, frag->page_offset + offset - start, copy, p, p_off, p_len, copied) { vaddr = kmap_atomic(p); csum2 = csum_partial_copy_nocheck(vaddr + p_off, to + copied, p_len, 0); kunmap_atomic(vaddr); csum = csum_block_add(csum, csum2, pos); pos += p_len; } if (!(len -= copy)) return csum; offset += copy; to += copy; } start = end; } skb_walk_frags(skb, frag_iter) { __wsum csum2; int end; WARN_ON(start > offset + len); end = start + frag_iter->len; if ((copy = end - offset) > 0) { if (copy > len) copy = len; csum2 = skb_copy_and_csum_bits(frag_iter, offset - start, to, copy, 0); csum = csum_block_add(csum, csum2, pos); if ((len -= copy) == 0) return csum; offset += copy; to += copy; pos += copy; } start = end; } BUG_ON(len); return csum;
0
[ "CWE-20" ]
linux
2b16f048729bf35e6c28a40cbfad07239f9dcd90
218,478,439,451,642,100,000,000,000,000,000,000,000
82
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]>
GF_Err leva_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox*)s; ISOM_DECREASE_SIZE(ptr, 1) ptr->level_count = gf_bs_read_u8(bs); //each level is at least 5 bytes if (ptr->size < ptr->level_count * 5) return GF_ISOM_INVALID_FILE; GF_SAFE_ALLOC_N(ptr->levels, ptr->level_count, GF_LevelAssignment); if (!ptr->levels) return GF_OUT_OF_MEM; for (i = 0; i < ptr->level_count; i++) { GF_LevelAssignment *level = &ptr->levels[i]; u8 tmp; if (!level || ptr->size < 5) return GF_BAD_PARAM; ISOM_DECREASE_SIZE(ptr, 5) level->track_id = gf_bs_read_u32(bs); tmp = gf_bs_read_u8(bs); level->padding_flag = tmp >> 7; level->type = tmp & 0x7F; if (level->type == 0) { ISOM_DECREASE_SIZE(ptr, 4) level->grouping_type = gf_bs_read_u32(bs); } else if (level->type == 1) { ISOM_DECREASE_SIZE(ptr, 8) level->grouping_type = gf_bs_read_u32(bs); level->grouping_type_parameter = gf_bs_read_u32(bs); } else if (level->type == 4) { ISOM_DECREASE_SIZE(ptr, 4) level->sub_track_id = gf_bs_read_u32(bs); } } return GF_OK;
0
[ "CWE-787" ]
gpac
388ecce75d05e11fc8496aa4857b91245007d26e
195,044,632,877,987,100,000,000,000,000,000,000,000
40
fixed #1587
static void do_signal(struct pt_regs *regs, unsigned int save_r0) { siginfo_t info; int signr; struct k_sigaction ka; sigset_t *oldset; /* * We want the common case to go fast, which * is why we may in certain cases get here from * kernel mode. Just return without doing anything * if so. */ if (!user_mode(regs)) return; if (try_to_freeze()) goto no_signal; if (test_thread_flag(TIF_RESTORE_SIGMASK)) oldset = &current->saved_sigmask; else oldset = &current->blocked; signr = get_signal_to_deliver(&info, &ka, regs, NULL); if (signr > 0) { handle_syscall_restart(save_r0, regs, &ka.sa); /* Whee! Actually deliver the signal. */ if (handle_signal(signr, &ka, &info, oldset, regs, save_r0) == 0) { /* a signal was successfully delivered; the saved * sigmask will have been stored in the signal frame, * and will be restored by sigreturn, so we can simply * clear the TIF_RESTORE_SIGMASK flag */ if (test_thread_flag(TIF_RESTORE_SIGMASK)) clear_thread_flag(TIF_RESTORE_SIGMASK); tracehook_signal_handler(signr, &info, &ka, regs, test_thread_flag(TIF_SINGLESTEP)); } return; } no_signal: /* Did we come from a system call? */ if (regs->tra >= 0) { /* Restart the system call - no handlers present */ if (regs->regs[0] == -ERESTARTNOHAND || regs->regs[0] == -ERESTARTSYS || regs->regs[0] == -ERESTARTNOINTR) { regs->regs[0] = save_r0; regs->pc -= instruction_size(ctrl_inw(regs->pc - 4)); } else if (regs->regs[0] == -ERESTART_RESTARTBLOCK) { regs->pc -= instruction_size(ctrl_inw(regs->pc - 4)); regs->regs[3] = __NR_restart_syscall; } } /* if there's no signal to deliver, we just put the saved sigmask * back */ if (test_thread_flag(TIF_RESTORE_SIGMASK)) { clear_thread_flag(TIF_RESTORE_SIGMASK); sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); } }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
190,738,967,344,395,450,000,000,000,000,000,000,000
67
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
qf_jump_to_buffer( qf_info_T *qi, int qf_index, qfline_T *qf_ptr, int forceit, int prev_winid, int *opened_window, int openfold, int print_message) { buf_T *old_curbuf; linenr_T old_lnum; int retval = OK; // If there is a file name, read the wanted file if needed, and check // autowrite etc. old_curbuf = curbuf; old_lnum = curwin->w_cursor.lnum; if (qf_ptr->qf_fnum != 0) { retval = qf_jump_edit_buffer(qi, qf_ptr, forceit, prev_winid, opened_window); if (retval != OK) return retval; } // When not switched to another buffer, still need to set pc mark if (curbuf == old_curbuf) setpcmark(); qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, qf_ptr->qf_pattern); #ifdef FEAT_FOLDING if ((fdo_flags & FDO_QUICKFIX) && openfold) foldOpenCursor(); #endif if (print_message) qf_jump_print_msg(qi, qf_index, qf_ptr, old_curbuf, old_lnum); return retval; }
0
[ "CWE-416" ]
vim
4f1b083be43f351bc107541e7b0c9655a5d2c0bb
28,844,618,662,512,564,000,000,000,000,000,000,000
43
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.
static void __blk_rq_prep_clone(struct request *dst, struct request *src) { dst->cpu = src->cpu; dst->__sector = blk_rq_pos(src); dst->__data_len = blk_rq_bytes(src); if (src->rq_flags & RQF_SPECIAL_PAYLOAD) { dst->rq_flags |= RQF_SPECIAL_PAYLOAD; dst->special_vec = src->special_vec; } dst->nr_phys_segments = src->nr_phys_segments; dst->ioprio = src->ioprio; dst->extra_len = src->extra_len; }
0
[ "CWE-416", "CWE-703" ]
linux
54648cf1ec2d7f4b6a71767799c45676a138ca24
160,776,591,765,242,160,000,000,000,000,000,000,000
13
block: blk_init_allocated_queue() set q->fq as NULL in the fail case We find the memory use-after-free issue in __blk_drain_queue() on the kernel 4.14. After read the latest kernel 4.18-rc6 we think it has the same problem. Memory is allocated for q->fq in the blk_init_allocated_queue(). If the elevator init function called with error return, it will run into the fail case to free the q->fq. Then the __blk_drain_queue() uses the same memory after the free of the q->fq, it will lead to the unpredictable event. The patch is to set q->fq as NULL in the fail case of blk_init_allocated_queue(). Fixes: commit 7c94e1c157a2 ("block: introduce blk_flush_queue to drive flush machinery") Cc: <[email protected]> Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: xiao jin <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static int jpc_cox_getcompparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in, int prtflag, jpc_coxcp_t *compparms) { uint_fast8_t tmp; int i; /* Eliminate compiler warning about unused variables. */ ms = 0; cstate = 0; if (jpc_getuint8(in, &compparms->numdlvls) || jpc_getuint8(in, &compparms->cblkwidthval) || jpc_getuint8(in, &compparms->cblkheightval) || jpc_getuint8(in, &compparms->cblksty) || jpc_getuint8(in, &compparms->qmfbid)) { return -1; } compparms->numrlvls = compparms->numdlvls + 1; if (prtflag) { for (i = 0; i < compparms->numrlvls; ++i) { if (jpc_getuint8(in, &tmp)) { jpc_cox_destroycompparms(compparms); return -1; } compparms->rlvls[i].parwidthval = tmp & 0xf; compparms->rlvls[i].parheightval = (tmp >> 4) & 0xf; } /* Sigh. This bit should be in the same field in both COC and COD mrk segs. */ compparms->csty |= JPC_COX_PRT; } else { } if (jas_stream_eof(in)) { jpc_cox_destroycompparms(compparms); return -1; } return 0; }
1
[ "CWE-119" ]
jasper
0d22460816ea58e74a124158fa6cc48efb709a47
93,503,931,966,798,470,000,000,000,000,000,000,000
37
Incorporated changes from patch jasper-1.900.3-CVE-2011-4516-CVE-2011-4517-CERT-VU-887409.patch
TEST_F(EncryptionUtilTest, sm4_with_iv_test_by_case) { std::string case_1 = "9FFlX59+3EbIC7rqylMNwg=="; // base64 for encrypted "hello, doris" std::string source_1 = "hello, doris"; std::string case_2 = "RIJVVUUmMT/4CVNYdxVvXA=="; // base64 for encrypted "doris test" std::string source_2 = "doris test"; std::string iv = "doris"; std::unique_ptr<char[]> encrypt_1(new char[case_1.length()]); int length_1 = base64_decode(case_1.c_str(), case_1.length(), encrypt_1.get()); std::unique_ptr<char[]> decrypted_1(new char[case_1.length()]); std::unique_ptr<char[]> decrypted_11(new char[case_1.length()]); int ret_code = EncryptionUtil::decrypt(SM4_128_CBC, (unsigned char*)encrypt_1.get(), length_1, (unsigned char*)_aes_key.c_str(), _aes_key.length(), iv.c_str(), true, (unsigned char*)decrypted_1.get()); ASSERT_TRUE(ret_code > 0); std::string decrypted_content_1(decrypted_1.get(), ret_code); ASSERT_EQ(source_1, decrypted_content_1); std::unique_ptr<char[]> encrypt_2(new char[case_2.length()]); int length_2 = base64_decode(case_2.c_str(), case_2.length(), encrypt_2.get()); std::unique_ptr<char[]> decrypted_2(new char[case_2.length()]); std::unique_ptr<char[]> decrypted_21(new char[case_2.length()]); ret_code = EncryptionUtil::decrypt(SM4_128_CBC, (unsigned char*)encrypt_2.get(), length_2, (unsigned char*)_aes_key.c_str(), _aes_key.length(), iv.c_str(), true, (unsigned char*)decrypted_2.get()); ASSERT_TRUE(ret_code > 0); std::string decrypted_content_2(decrypted_2.get(), ret_code); ASSERT_EQ(source_2, decrypted_content_2); ret_code = EncryptionUtil::decrypt(SM4_128_CBC, (unsigned char*)encrypt_1.get(), length_1, (unsigned char*)_aes_key.c_str(), _aes_key.length(), iv.c_str(), true, (unsigned char*)decrypted_11.get()); ASSERT_TRUE(ret_code > 0); std::string decrypted_content_11(decrypted_11.get(), ret_code); ASSERT_EQ(source_1, decrypted_content_11); ret_code = EncryptionUtil::decrypt(SM4_128_CBC, (unsigned char*)encrypt_2.get(), length_2, (unsigned char*)_aes_key.c_str(), _aes_key.length(), iv.c_str(), true, (unsigned char*)decrypted_21.get()); ASSERT_TRUE(ret_code > 0); std::string decrypted_content_21(decrypted_21.get(), ret_code); ASSERT_EQ(source_2, decrypted_content_21); }
0
[ "CWE-200" ]
incubator-doris
246ac4e37aa4da6836b7850cb990f02d1c3725a3
106,106,073,698,694,870,000,000,000,000,000,000,000
45
[fix] fix a bug of encryption function with iv may return wrong result (#8277)
on_unregister_handler(TCMUService1HandlerManager1 *interface, GDBusMethodInvocation *invocation, gchar *subtype, gpointer user_data) { struct tcmur_handler *handler = find_handler_by_subtype(subtype); struct dbus_info *info = handler->opaque; if (!handler) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(bs)", FALSE, "unknown subtype")); return TRUE; } dbus_unexport_handler(handler); tcmur_unregister_handler(handler); g_bus_unwatch_name(info->watcher_id); g_free(info); g_free(handler); g_dbus_method_invocation_return_value(invocation, g_variant_new("(bs)", TRUE, "succeeded")); return TRUE; }
1
[ "CWE-20" ]
tcmu-runner
e2d953050766ac538615a811c64b34358614edce
6,353,029,372,427,723,000,000,000,000,000,000,000
23
fixed local DoS when UnregisterHandler was called for a not existing handler Any user with DBUS access could cause a SEGFAULT in tcmu-runner by running something like this: dbus-send --system --print-reply --dest=org.kernel.TCMUService1 /org/kernel/TCMUService1/HandlerManager1 org.kernel.TCMUService1.HandlerManager1.UnregisterHandler string:123
static TEE_Result set_rmem_param(const struct optee_msg_param_rmem *rmem, struct param_mem *mem) { uint64_t shm_ref = READ_ONCE(rmem->shm_ref); mem->mobj = mobj_reg_shm_get_by_cookie(shm_ref); if (!mem->mobj) return TEE_ERROR_BAD_PARAMETERS; mem->offs = READ_ONCE(rmem->offs); mem->size = READ_ONCE(rmem->size); return TEE_SUCCESS; }
1
[ "CWE-20", "CWE-119", "CWE-787" ]
optee_os
e3adcf566cb278444830e7badfdcc3983e334fd1
105,544,219,581,311,630,000,000,000,000,000,000,000
14
core: ensure that supplied range matches MOBJ In set_rmem_param() if the MOBJ is found by the cookie it's verified to represent non-secure shared memory. Prior to this patch the supplied sub-range to be used of the MOBJ was not checked here and relied on later checks further down the chain. Those checks seems to be enough for user TAs, but not for pseudo TAs where the size isn't checked. This patch adds a check for offset and size to see that they remain inside the memory covered by the MOBJ. Fixes: OP-TEE-2018-0004: "Unchecked parameters are passed through from REE". Signed-off-by: Jens Wiklander <[email protected]> Tested-by: Joakim Bech <[email protected]> (QEMU v7, v8) Reviewed-by: Joakim Bech <[email protected]> Reported-by: Riscure <[email protected]> Reported-by: Alyssa Milburn <[email protected]> Acked-by: Etienne Carriere <[email protected]>
Item *Item_sum_udf_decimal::copy_or_same(THD* thd) { return new (thd->mem_root) Item_sum_udf_decimal(thd, this); }
0
[ "CWE-120" ]
server
eca207c46293bc72dd8d0d5622153fab4d3fccf1
64,101,332,540,885,740,000,000,000,000,000,000,000
4
MDEV-25317 Assertion `scale <= precision' failed in decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' failed in decimal_bin_size_inline/decimal_bin_size. Precision should be kept below DECIMAL_MAX_SCALE for computations. It can be bigger in Item_decimal. I'd fix this too but it changes the existing behaviour so problemmatic to ix.
void HGraphBuilder::VisitForEffect(Expression* expr) { EffectContext for_effect(this); Visit(expr); }
0
[]
node
fd80a31e0697d6317ce8c2d289575399f4e06d21
174,163,226,149,982,600,000,000,000,000,000,000,000
4
deps: backport 5f836c from v8 upstream Original commit message: Fix Hydrogen bounds check elimination When combining bounds checks, they must all be moved before the first load/store that they are guarding. BUG=chromium:344186 LOG=y [email protected] Review URL: https://codereview.chromium.org/172093002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@19475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 fix #8070
static struct sock *__sco_get_sock_listen_by_addr(bdaddr_t *ba) { struct sock *sk; sk_for_each(sk, &sco_sk_list.head) { if (sk->sk_state != BT_LISTEN) continue; if (!bacmp(&bt_sk(sk)->src, ba)) return sk; } return NULL; }
0
[ "CWE-200" ]
linux
c8c499175f7d295ef867335bceb9a76a2c3cdc38
320,303,792,239,223,640,000,000,000,000,000,000,000
14
Bluetooth: SCO - Fix missing msg_namelen update in sco_sock_recvmsg() If the socket is in state BT_CONNECT2 and BT_SK_DEFER_SETUP is set in the flags, sco_sock_recvmsg() returns early with 0 without updating the possibly set msg_namelen member. This, in turn, leads to a 128 byte kernel stack leak in net/socket.c. Fix this by updating msg_namelen in this case. For all other cases it will be handled in bt_sock_recvmsg(). Cc: Marcel Holtmann <[email protected]> Cc: Gustavo Padovan <[email protected]> Cc: Johan Hedberg <[email protected]> Signed-off-by: Mathias Krause <[email protected]> Signed-off-by: David S. Miller <[email protected]>
find_definition(const char *name, size_t len, bool definition) { element e; def_t *def; const char *p; bool using_braces = false; bool allow_multiline; if (LIST_ISEMPTY(defs)) return NULL; if (!definition && *name == BOB[0]) { using_braces = true; name++; } if (!isalpha(*name) && *name != '_') return NULL; if (!len) { for (len = 1, p = name + 1; *p != '\0' && (isalnum(*p) || *p == '_'); len++, p++); /* Check we have a suitable end character */ if (using_braces && *p != EOB[0]) return NULL; if (!using_braces && !definition && *p != ' ' && *p != '\t' && *p != '\0') return NULL; } if (definition || (!using_braces && name[len] == '\0') || (using_braces && name[len+1] == '\0')) allow_multiline = true; else allow_multiline = false; for (e = LIST_HEAD(defs); e; ELEMENT_NEXT(e)) { def = ELEMENT_DATA(e); if (def->name_len == len && (allow_multiline || !def->multiline) && !strncmp(def->name, name, len)) return def; } return NULL; }
0
[ "CWE-59", "CWE-61" ]
keepalived
04f2d32871bb3b11d7dc024039952f2fe2750306
145,558,376,803,514,060,000,000,000,000,000,000,000
48
When opening files for write, ensure they aren't symbolic links Issue #1048 identified that if, for example, a non privileged user created a symbolic link from /etc/keepalvied.data to /etc/passwd, writing to /etc/keepalived.data (which could be invoked via DBus) would cause /etc/passwd to be overwritten. This commit stops keepalived writing to pathnames where the ultimate component is a symbolic link, by setting O_NOFOLLOW whenever opening a file for writing. This might break some setups, where, for example, /etc/keepalived.data was a symbolic link to /home/fred/keepalived.data. If this was the case, instead create a symbolic link from /home/fred/keepalived.data to /tmp/keepalived.data, so that the file is still accessible via /home/fred/keepalived.data. There doesn't appear to be a way around this backward incompatibility, since even checking if the pathname is a symbolic link prior to opening for writing would create a race condition. Signed-off-by: Quentin Armitage <[email protected]>
cudnnDirectionMode_t ToCudnnRnnDirectionMode( dnn::RnnDirectionMode direction_mode) { switch (direction_mode) { case dnn::RnnDirectionMode::kRnnUnidirectional: case dnn::RnnDirectionMode::kRnnBidirectional: return static_cast<cudnnDirectionMode_t>(direction_mode); default: LOG(FATAL) << "Invalid RNN direction mode: " << static_cast<int>(direction_mode); } }
0
[ "CWE-20" ]
tensorflow
14755416e364f17fb1870882fa778c7fec7f16e3
98,514,476,391,773,460,000,000,000,000,000,000,000
11
Prevent CHECK-fail in LSTM/GRU with zero-length input. PiperOrigin-RevId: 346239181 Change-Id: I5f233dbc076aab7bb4e31ba24f5abd4eaf99ea4f
xfs_attr3_leaf_clearflag( struct xfs_da_args *args) { struct xfs_attr_leafblock *leaf; struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_name_remote *name_rmt; struct xfs_buf *bp; int error; #ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr; xfs_attr_leaf_name_local_t *name_loc; int namelen; char *name; #endif /* DEBUG */ trace_xfs_attr_leaf_clearflag(args); /* * Set up the operation. */ error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); if (error) return error; leaf = bp->b_addr; entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; ASSERT(entry->flags & XFS_ATTR_INCOMPLETE); #ifdef DEBUG xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf); ASSERT(args->index < ichdr.count); ASSERT(args->index >= 0); if (entry->flags & XFS_ATTR_LOCAL) { name_loc = xfs_attr3_leaf_name_local(leaf, args->index); namelen = name_loc->namelen; name = (char *)name_loc->nameval; } else { name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); namelen = name_rmt->namelen; name = (char *)name_rmt->name; } ASSERT(be32_to_cpu(entry->hashval) == args->hashval); ASSERT(namelen == args->namelen); ASSERT(memcmp(name, args->name, namelen) == 0); #endif /* DEBUG */ entry->flags &= ~XFS_ATTR_INCOMPLETE; xfs_trans_log_buf(args->trans, bp, XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); if (args->rmtblkno) { ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0); name_rmt = xfs_attr3_leaf_name_remote(leaf, args->index); name_rmt->valueblk = cpu_to_be32(args->rmtblkno); name_rmt->valuelen = cpu_to_be32(args->rmtvaluelen); xfs_trans_log_buf(args->trans, bp, XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); } /* * Commit the flag value change and start the next trans in series. */ return xfs_trans_roll_inode(&args->trans, args->dp); }
0
[ "CWE-476" ]
linux
bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a
270,061,386,578,871,580,000,000,000,000,000,000,000
64
xfs: don't call xfs_da_shrink_inode with NULL bp xfs_attr3_leaf_create may have errored out before instantiating a buffer, for example if the blkno is out of range. In that case there is no work to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops if we try. This also seems to fix a flaw where the original error from xfs_attr3_leaf_create gets overwritten in the cleanup case, and it removes a pointless assignment to bp which isn't used after this. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969 Reported-by: Xu, Wen <[email protected]> Tested-by: Xu, Wen <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
static ssize_t proc_read( struct file *file, char __user *buffer, size_t len, loff_t *offset ) { struct proc_data *priv = file->private_data; if (!priv->rbuffer) return -EINVAL; return simple_read_from_buffer(buffer, len, offset, priv->rbuffer, priv->readlen); }
0
[ "CWE-703", "CWE-264" ]
linux
550fd08c2cebad61c548def135f67aba284c6162
290,552,611,417,589,640,000,000,000,000,000,000,000
13
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 void init_rangecoder(RangeCoder *rc, GetByteContext *gb) { rc->code1 = 0; rc->range = 0xFFFFFFFFU; rc->code = bytestream2_get_be32(gb); }
0
[ "CWE-119", "CWE-787" ]
FFmpeg
2171dfae8c065878a2e130390eb78cf2947a5b69
275,516,044,643,633,500,000,000,000,000,000,000,000
6
avcodec/scpr: Fix multiple runtime error: index 256 out of bounds for type 'unsigned int [256]' Fixes: 1519/clusterfuzz-testcase-minimized-5286680976162816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <[email protected]>
static int double_lock_balance(struct rq *this_rq, struct rq *busiest) { if (unlikely(!irqs_disabled())) { /* printk() doesn't work good under rq->lock */ raw_spin_unlock(&this_rq->lock); BUG_ON(1); } return _double_lock_balance(this_rq, busiest); }
0
[ "CWE-703", "CWE-835" ]
linux
f26f9aff6aaf67e9a430d16c266f91b13a5bff64
272,633,058,365,043,100,000,000,000,000,000,000,000
10
Sched: fix skip_clock_update optimization idle_balance() drops/retakes rq->lock, leaving the previous task vulnerable to set_tsk_need_resched(). Clear it after we return from balancing instead, and in setup_thread_stack() as well, so no successfully descheduled or never scheduled task has it set. Need resched confused the skip_clock_update logic, which assumes that the next call to update_rq_clock() will come nearly immediately after being set. Make the optimization robust against the waking a sleeper before it sucessfully deschedules case by checking that the current task has not been dequeued before setting the flag, since it is that useless clock update we're trying to save, and clear unconditionally in schedule() proper instead of conditionally in put_prev_task(). Signed-off-by: Mike Galbraith <[email protected]> Reported-by: Bjoern B. Brandenburg <[email protected]> Tested-by: Yong Zhang <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Cc: [email protected] LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
rrset_parse_equals(struct rrset_parse* p, sldns_buffer* pkt, hashvalue_type h, uint32_t rrset_flags, uint8_t* dname, size_t dnamelen, uint16_t type, uint16_t dclass) { if(p->hash == h && p->dname_len == dnamelen && p->type == type && p->rrset_class == dclass && p->flags == rrset_flags && dname_pkt_compare(pkt, dname, p->dname) == 0) return 1; return 0; }
0
[ "CWE-400" ]
unbound
ba0f382eee814e56900a535778d13206b86b6d49
79,188,047,429,297,480,000,000,000,000,000,000,000
10
- CVE-2020-12662 Unbound can be tricked into amplifying an incoming query into a large number of queries directed to a target. - CVE-2020-12663 Malformed answers from upstream name servers can be used to make Unbound unresponsive.
void seq_put_decimal_ll(struct seq_file *m, const char *delimiter, long long num) { int len; if (m->count + 3 >= m->size) /* we'll write 2 bytes at least */ goto overflow; if (delimiter && delimiter[0]) { if (delimiter[1] == 0) seq_putc(m, delimiter[0]); else seq_puts(m, delimiter); } if (m->count + 2 >= m->size) goto overflow; if (num < 0) { m->buf[m->count++] = '-'; num = -num; } if (num < 10) { m->buf[m->count++] = num + '0'; return; } len = num_to_str(m->buf + m->count, m->size - m->count, num, 0); if (!len) goto overflow; m->count += len; return; overflow: seq_set_overflow(m); }
0
[ "CWE-120", "CWE-787" ]
linux
8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b
45,054,344,622,086,580,000,000,000,000,000,000,000
37
seq_file: disallow extremely large seq buffer allocations There is no reasonable need for a buffer larger than this, and it avoids int overflow pitfalls. Fixes: 058504edd026 ("fs/seq_file: fallback to vmalloc allocation") Suggested-by: Al Viro <[email protected]> Reported-by: Qualys Security Advisory <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options) { xmlParserInputBufferPtr input; xmlParserInputPtr stream; if (ctxt == NULL) return (NULL); if (buffer == NULL) return (NULL); htmlCtxtReset(ctxt); input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); if (input == NULL) { return(NULL); } stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); if (stream == NULL) { xmlFreeParserInputBuffer(input); return(NULL); } inputPush(ctxt, stream); return (htmlDoRead(ctxt, URL, encoding, options, 1)); }
0
[ "CWE-399" ]
libxml2
de0cc20c29cb3f056062925395e0f68d2250a46f
231,901,741,055,225,500,000,000,000,000,000,000,000
27
Fix some buffer conversion issues https://bugzilla.gnome.org/show_bug.cgi?id=690202 Buffer overflow errors originating from xmlBufGetInputBase in 2.9.0 The pointers from the context input were not properly reset after that call which can do reallocations.
const Cluster* BlockEntry::GetCluster() const { return m_pCluster; }
0
[ "CWE-20" ]
libvpx
34d54b04e98dd0bac32e9aab0fbda0bf501bc742
82,064,440,425,049,320,000,000,000,000,000,000,000
1
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
void DL_Dxf::write3dFace(DL_WriterA& dw, const DL_3dFaceData& data, const DL_Attributes& attrib) { dw.entity("3DFACE"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbEntity"); } dw.entityAttributes(attrib); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbFace"); } dw.coord(10, data.x[0], data.y[0], data.z[0]); dw.coord(11, data.x[1], data.y[1], data.z[1]); dw.coord(12, data.x[2], data.y[2], data.z[2]); dw.coord(13, data.x[3], data.y[3], data.z[3]); }
0
[ "CWE-191" ]
qcad
1eeffc5daf5a06cf6213ffc19e95923cdebb2eb8
38,385,928,040,055,053,000,000,000,000,000,000,000
16
check vertexIndex which might be -1 for broken DXF
const vector<CChan*>& CIRCNetwork::GetChans() const { return m_vChans; }
0
[ "CWE-20" ]
znc
64613bc8b6b4adf1e32231f9844d99cd512b8973
153,367,481,437,506,100,000,000,000,000,000,000,000
1
Don't crash if user specified invalid encoding. This is CVE-2019-9917
base::string16 GetDefaultPrinterAsync() { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); scoped_refptr<printing::PrintBackend> backend = printing::PrintBackend::CreateInstance( nullptr, g_browser_process->GetApplicationLocale()); std::string printer_name = backend->GetDefaultPrinterName(); return base::UTF8ToUTF16(printer_name); }
0
[ "CWE-284", "CWE-693" ]
electron
18613925610ba319da7f497b6deed85ad712c59b
132,985,805,445,442,270,000,000,000,000,000,000,000
10
refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25108) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL (#25065) * refactor: wire will-navigate up to a navigation throttle instead of OpenURL * spec: add test for x-site _top navigation * chore: old code be old
TEST(QueryProjectionTest, SortKeyMetaAndSlice) { auto proj = createFindProjection("{}", "{a: 1, foo: {$meta: 'sortKey'}, _id: 0, b: {$slice: 1}}"); ASSERT_TRUE(proj.metadataDeps()[DocumentMetadataFields::kSortKey]); ASSERT_TRUE(proj.requiresDocument()); ASSERT_FALSE(proj.requiresMatchDetails()); ASSERT_FALSE(proj.metadataDeps()[DocumentMetadataFields::kGeoNearDist]); ASSERT_FALSE(proj.metadataDeps()[DocumentMetadataFields::kGeoNearPoint]); }
0
[ "CWE-732" ]
mongo
cd583b6c4d8aa2364f255992708b9bb54e110cf4
165,614,108,937,510,190,000,000,000,000,000,000,000
10
SERVER-53929 Add stricter parser checks around positional projection
DT_2_IndicatePData(PRIVATE_NETWORKKEY ** /*network*/, PRIVATE_ASSOCIATIONKEY ** association, int nextState, void * /*params*/) { unsigned char pduType, pduReserved; unsigned long pduLength, pdvLength, pdvCount; long length; unsigned char *p; /* determine the finite state machine's next state */ (*association)->protocolState = nextState; /* read PDU body information from the incoming socket stream. In case the incoming */ /* PDU's header information has not yet been read, also read this information. */ OFCondition cond = readPDUBody(association, DUL_BLOCK, 0, (*association)->fragmentBuffer, (*association)->fragmentBufferLength, &pduType, &pduReserved, &pduLength); /* return error if there was one */ if (cond.bad()) return cond; /* count the amount of PDVs in the current PDU */ length = pduLength; //set length to the PDU's length pdvCount = 0; //set counter variable to 0 p = (*association)->fragmentBuffer; //set p to the buffer which contains the PDU's PDVs while (length >= 4) { //as long as length is at least 4 (= a length field can be read) EXTRACT_LONG_BIG(p, pdvLength); //determine the length of the current PDV (the PDV p points to) p += 4 + pdvLength; //move p so that it points to the next PDV (move p 4 bytes over the length field plus the amount of bytes which is captured in the PDV's length field (over presentation context.Id, message information header and data fragment)) length -= 4 + pdvLength; //update length (i.e. determine the length of the buffer which has not been evaluated yet.) pdvCount++; //increase counter by one, since we've found another PDV // There must be at least a presentation context ID and a message // control header (see below), else the calculation pdvLength - 2 below // will underflow. if (pdvLength < 2) { char buf[256]; sprintf(buf, "PDV with invalid length %lu encountered. This probably indicates a malformed P DATA PDU.", pdvLength); return makeDcmnetCondition(DULC_ILLEGALPDULENGTH, OF_error, buf); } } /* if after having counted the PDVs the length variable does not equal */ /* 0, the PDV lengths did not add up correctly. Something is fishy. */ if (length != 0) { char buf[256]; sprintf(buf, "PDV lengths don't add up correctly: %d PDVs. This probably indicates a malformed P-DATA PDU. PDU type is %02x.", (int)pdvCount, (unsigned int) pduType); return makeDcmnetCondition(DULC_ILLEGALPDU, OF_error, buf); } /* let the the association indicate how many PDVs are contained in the PDU */ (*association)->pdvCount = (int)pdvCount; /* if at least one PDV is contained in the PDU, the association's pdvIndex has to be set to 0 */ if (pdvCount > 0) (*association)->pdvIndex = 0; else { /* if there is no PDV contained in the PDU, the association's pdvIndex has to be set to -1 */ (*association)->pdvIndex = -1; /* bugfix by wilkens 01/10/12: return error if PDU does not contain any PDVs: */ /* Additionally, it is not allowed to have a PDU that does not contain any PDVs. */ /* Hence, return an error (see DICOM standard (year 2000) part 8, section 9.3.1, */ /* figure 9-2) (or the corresponding section in a later version of the standard) */ char buf[256]; sprintf(buf, "PDU without any PDVs encountered. In DT_2_IndicatePData. This probably indicates a malformed P DATA PDU." ); return makeDcmnetCondition(DULC_ILLEGALPDU, OF_error, buf); } /* at this point we need to set the association's currentPDV variable so that it contains the data */ /* of the next unprocessed PDV (currentPDV shall always contain the next unprocessed PDV's data.) */ /* set the fragment buffer (the buffer which contains all PDVs of the current PDU) to a local variable */ p = (*association)->fragmentBuffer; /* The variable (*association)->pdvPointer always points to the buffer */ /* address where the information of the PDV which is represented by the */ /* association's currentPDV variable can be found. Set this variable. */ (*association)->pdvPointer = p; /* determine the value in the PDV length field of the next (unprocessed) PDV */ EXTRACT_LONG_BIG(p, pdvLength); /* set the data fragment length in the association's currentPDV.fragmentLength variable */ /* (we start now overwriting all the entries in (*association)->currentPDV). The actual */ /* length of the data fragment of the next (unprocessed) PDV equals the above determined */ /* length minus 1 byte (for the presentation context ID) and minus another byte (for the */ /* message control header). */ (*association)->currentPDV.fragmentLength = pdvLength - 2; /* set the presentation context ID value in the association's currentPDV.presentationContextID */ /* variable. This value is 1 byte wide and contained in the 5th byte of p (the first four bytes */ /* contain the PDV length value, the fifth byte the presentation context ID value) */ (*association)->currentPDV.presentationContextID = p[4]; /* now determine if the next (unprocessed) PDV contains the last fragment of a data set or DIMSE */ /* command and if the next (unprocessed) PDV is a data set PDV or command PDV. This information */ /* is captured in the 6th byte of p: */ unsigned char u = p[5]; if (u & 2) (*association)->currentPDV.lastPDV = OFTrue; //if bit 1 of the message control header is 1, this fragment does contain the last fragment of a data set or command else (*association)->currentPDV.lastPDV = OFFalse; //if bit 1 of the message control header is 0, this fragment does not contain the last fragment of a data set or command if (u & 1) (*association)->currentPDV.pdvType = DUL_COMMANDPDV; //if bit 0 of the message control header is 1, this is a command PDV else (*association)->currentPDV.pdvType = DUL_DATASETPDV; //if bit 0 of the message control header is 0, this is a data set PDV /* now assign the data fragment of the next (unprocessed) PDV to the association's */ /* currentPDV.data variable. The fragment starts 6 bytes to the right of the address */ /* p currently points to. */ (*association)->currentPDV.data = p + 6; /* return ok */ return DUL_PDATAPDUARRIVED; }
0
[ "CWE-415", "CWE-703", "CWE-401" ]
dcmtk
a9697dfeb672b0b9412c00c7d36d801e27ec85cb
302,785,127,224,060,500,000,000,000,000,000,000,000
127
Fixed poss. NULL pointer dereference/double free. Thanks to Jinsheng Ba <[email protected]> for the report and some patches.
item_compare(const void *s1, const void *s2) { sortItem_T *si1, *si2; typval_T *tv1, *tv2; char_u *p1, *p2; char_u *tofree1 = NULL, *tofree2 = NULL; int res; char_u numbuf1[NUMBUFLEN]; char_u numbuf2[NUMBUFLEN]; si1 = (sortItem_T *)s1; si2 = (sortItem_T *)s2; tv1 = &si1->item->li_tv; tv2 = &si2->item->li_tv; if (sortinfo->item_compare_numbers) { varnumber_T v1 = tv_get_number(tv1); varnumber_T v2 = tv_get_number(tv2); return v1 == v2 ? 0 : v1 > v2 ? 1 : -1; } #ifdef FEAT_FLOAT if (sortinfo->item_compare_float) { float_T v1 = tv_get_float(tv1); float_T v2 = tv_get_float(tv2); return v1 == v2 ? 0 : v1 > v2 ? 1 : -1; } #endif /* tv2string() puts quotes around a string and allocates memory. Don't do * that for string variables. Use a single quote when comparing with a * non-string to do what the docs promise. */ if (tv1->v_type == VAR_STRING) { if (tv2->v_type != VAR_STRING || sortinfo->item_compare_numeric) p1 = (char_u *)"'"; else p1 = tv1->vval.v_string; } else p1 = tv2string(tv1, &tofree1, numbuf1, 0); if (tv2->v_type == VAR_STRING) { if (tv1->v_type != VAR_STRING || sortinfo->item_compare_numeric) p2 = (char_u *)"'"; else p2 = tv2->vval.v_string; } else p2 = tv2string(tv2, &tofree2, numbuf2, 0); if (p1 == NULL) p1 = (char_u *)""; if (p2 == NULL) p2 = (char_u *)""; if (!sortinfo->item_compare_numeric) { if (sortinfo->item_compare_ic) res = STRICMP(p1, p2); else res = STRCMP(p1, p2); } else { double n1, n2; n1 = strtod((char *)p1, (char **)&p1); n2 = strtod((char *)p2, (char **)&p2); res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1; } /* When the result would be zero, compare the item indexes. Makes the * sort stable. */ if (res == 0 && !sortinfo->item_compare_keep_zero) res = si1->idx > si2->idx ? 1 : -1; vim_free(tofree1); vim_free(tofree2); return res; }
0
[ "CWE-78" ]
vim
8c62a08faf89663e5633dc5036cd8695c80f1075
189,743,679,794,113,420,000,000,000,000,000,000,000
82
patch 8.1.0881: can execute shell commands in rvim through interfaces Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3) { xmlChar *buffer = NULL; int buffer_size = 0; xmlChar *current = NULL; xmlChar *rep = NULL; const xmlChar *last; xmlEntityPtr ent; int c,l; int nbchars = 0; if ((ctxt == NULL) || (str == NULL) || (len < 0)) return(NULL); last = str + len; if (((ctxt->depth > 40) && ((ctxt->options & XML_PARSE_HUGE) == 0)) || (ctxt->depth > 1024)) { xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); return(NULL); } /* * allocate a translation buffer. */ buffer_size = XML_PARSER_BIG_BUFFER_SIZE; buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); if (buffer == NULL) goto mem_error; /* * OK loop until we reach one of the ending char or a size limit. * we are operating on already parsed values. */ if (str < last) c = CUR_SCHAR(str, l); else c = 0; while ((c != 0) && (c != end) && /* non input consuming loop */ (c != end2) && (c != end3)) { if (c == 0) break; if ((c == '&') && (str[1] == '#')) { int val = xmlParseStringCharRef(ctxt, &str); if (val != 0) { COPY_BUF(0,buffer,nbchars,val); } if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } } else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) { if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "String decoding Entity Reference: %.30s\n", str); ent = xmlParseStringEntityRef(ctxt, &str); if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) || (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR)) goto int_error; if (ent != NULL) ctxt->nbentities += ent->checked; if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (ent->content != NULL) { COPY_BUF(0,buffer,nbchars,ent->content[0]); if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } } else { xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR, "predefined entity has no content\n"); } } else if ((ent != NULL) && (ent->content != NULL)) { ctxt->depth++; rep = xmlStringDecodeEntities(ctxt, ent->content, what, 0, 0, 0); ctxt->depth--; if (rep != NULL) { current = rep; while (*current != 0) { /* non input consuming loop */ buffer[nbchars++] = *current++; if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { if (xmlParserEntityCheck(ctxt, nbchars, ent)) goto int_error; growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } } xmlFree(rep); rep = NULL; } } else if (ent != NULL) { int i = xmlStrlen(ent->name); const xmlChar *cur = ent->name; buffer[nbchars++] = '&'; if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) { growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } for (;i > 0;i--) buffer[nbchars++] = *cur++; buffer[nbchars++] = ';'; } } else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) { if (xmlParserDebugEntities) xmlGenericError(xmlGenericErrorContext, "String decoding PE Reference: %.30s\n", str); ent = xmlParseStringPEReference(ctxt, &str); if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP) goto int_error; if (ent != NULL) ctxt->nbentities += ent->checked; if (ent != NULL) { if (ent->content == NULL) { xmlLoadEntityContent(ctxt, ent); } ctxt->depth++; rep = xmlStringDecodeEntities(ctxt, ent->content, what, 0, 0, 0); ctxt->depth--; if (rep != NULL) { current = rep; while (*current != 0) { /* non input consuming loop */ buffer[nbchars++] = *current++; if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { if (xmlParserEntityCheck(ctxt, nbchars, ent)) goto int_error; growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } } xmlFree(rep); rep = NULL; } } } else { COPY_BUF(l,buffer,nbchars,c); str += l; if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) { growBuffer(buffer, XML_PARSER_BUFFER_SIZE); } } if (str < last) c = CUR_SCHAR(str, l); else c = 0; } buffer[nbchars] = 0; return(buffer); mem_error: xmlErrMemory(ctxt, NULL); int_error: if (rep != NULL) xmlFree(rep); if (buffer != NULL) xmlFree(buffer); return(NULL); }
1
[ "CWE-787" ]
libxml2
5bd3c061823a8499b27422aee04ea20aae24f03e
53,910,393,112,831,720,000,000,000,000,000,000,000
160
Fix an allocation error when copying entities
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS_EX pEntryPoints, PVOID pInitHandle) { UINT rc; drdynvcPlugin* drdynvc; DrdynvcClientContext* context = NULL; CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx; drdynvc = (drdynvcPlugin*) calloc(1, sizeof(drdynvcPlugin)); if (!drdynvc) { WLog_ERR(TAG, "calloc failed!"); return FALSE; } drdynvc->channelDef.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP | CHANNEL_OPTION_COMPRESS_RDP; sprintf_s(drdynvc->channelDef.name, ARRAYSIZE(drdynvc->channelDef.name), "drdynvc"); drdynvc->state = DRDYNVC_STATE_INITIAL; pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints; if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) && (pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER)) { context = (DrdynvcClientContext*) calloc(1, sizeof(DrdynvcClientContext)); if (!context) { WLog_Print(drdynvc->log, WLOG_ERROR, "calloc failed!"); free(drdynvc); return FALSE; } context->handle = (void*) drdynvc; context->custom = NULL; drdynvc->context = context; context->GetVersion = drdynvc_get_version; drdynvc->rdpcontext = pEntryPointsEx->context; } drdynvc->log = WLog_Get(TAG); WLog_Print(drdynvc->log, WLOG_DEBUG, "VirtualChannelEntryEx"); CopyMemory(&(drdynvc->channelEntryPoints), pEntryPoints, sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)); drdynvc->InitHandle = pInitHandle; rc = drdynvc->channelEntryPoints.pVirtualChannelInitEx(drdynvc, context, pInitHandle, &drdynvc->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, drdynvc_virtual_channel_init_event_ex); if (CHANNEL_RC_OK != rc) { WLog_Print(drdynvc->log, WLOG_ERROR, "pVirtualChannelInit failed with %s [%08"PRIX32"]", WTSErrorToString(rc), rc); free(drdynvc->context); free(drdynvc); return FALSE; } drdynvc->channelEntryPoints.pInterface = context; return TRUE; }
0
[ "CWE-125" ]
FreeRDP
baee520e3dd9be6511c45a14c5f5e77784de1471
259,154,303,433,120,640,000,000,000,000,000,000,000
60
Fix for #4866: Added additional length checks
static void kvm_update_dr6(struct kvm_vcpu *vcpu) { if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) kvm_x86_ops->set_dr6(vcpu, vcpu->arch.dr6); }
0
[ "CWE-119", "CWE-703", "CWE-120" ]
linux
a08d3b3b99efd509133946056531cdf8f3a0c09b
10,901,838,190,695,787,000,000,000,000,000,000,000
5
kvm: x86: fix emulator buffer overflow (CVE-2014-0049) The problem occurs when the guest performs a pusha with the stack address pointing to an mmio address (or an invalid guest physical address) to start with, but then extending into an ordinary guest physical address. When doing repeated emulated pushes emulator_read_write sets mmio_needed to 1 on the first one. On a later push when the stack points to regular memory, mmio_nr_fragments is set to 0, but mmio_is_needed is not set to 0. As a result, KVM exits to userspace, and then returns to complete_emulated_mmio. In complete_emulated_mmio vcpu->mmio_cur_fragment is incremented. The termination condition of vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments is never achieved. The code bounces back and fourth to userspace incrementing mmio_cur_fragment past it's buffer. If the guest does nothing else it eventually leads to a a crash on a memcpy from invalid memory address. However if a guest code can cause the vm to be destroyed in another vcpu with excellent timing, then kvm_clear_async_pf_completion_queue can be used by the guest to control the data that's pointed to by the call to cancel_work_item, which can be used to gain execution. Fixes: f78146b0f9230765c6315b2e14f56112513389ad Signed-off-by: Andrew Honig <[email protected]> Cc: [email protected] (3.5+) Signed-off-by: Paolo Bonzini <[email protected]>
int ax25_fwd_ioctl(unsigned int cmd, struct ax25_fwd_struct *fwd) { ax25_dev *ax25_dev, *fwd_dev; if ((ax25_dev = ax25_addr_ax25dev(&fwd->port_from)) == NULL) return -EINVAL; switch (cmd) { case SIOCAX25ADDFWD: if ((fwd_dev = ax25_addr_ax25dev(&fwd->port_to)) == NULL) return -EINVAL; if (ax25_dev->forward != NULL) return -EINVAL; ax25_dev->forward = fwd_dev->dev; break; case SIOCAX25DELFWD: if (ax25_dev->forward == NULL) return -EINVAL; ax25_dev->forward = NULL; break; default: return -EINVAL; } return 0; }
1
[ "CWE-416" ]
linux
d01ffb9eee4af165d83b08dd73ebdf9fe94a519b
25,960,141,028,206,120,000,000,000,000,000,000,000
28
ax25: add refcount in ax25_dev to avoid UAF bugs If we dereference ax25_dev after we call kfree(ax25_dev) in ax25_dev_device_down(), it will lead to concurrency UAF bugs. There are eight syscall functions suffer from UAF bugs, include ax25_bind(), ax25_release(), ax25_connect(), ax25_ioctl(), ax25_getname(), ax25_sendmsg(), ax25_getsockopt() and ax25_info_show(). One of the concurrency UAF can be shown as below: (USE) | (FREE) | ax25_device_event | ax25_dev_device_down ax25_bind | ... ... | kfree(ax25_dev) ax25_fillin_cb() | ... ax25_fillin_cb_from_dev() | ... | The root cause of UAF bugs is that kfree(ax25_dev) in ax25_dev_device_down() is not protected by any locks. When ax25_dev, which there are still pointers point to, is released, the concurrency UAF bug will happen. This patch introduces refcount into ax25_dev in order to guarantee that there are no pointers point to it when ax25_dev is released. Signed-off-by: Duoming Zhou <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static void *atalk_seq_interface_next(struct seq_file *seq, void *v, loff_t *pos) { struct atalk_iface *i; ++*pos; if (v == SEQ_START_TOKEN) { i = NULL; if (atalk_interfaces) i = atalk_interfaces; goto out; } i = v; i = i->next; out: return i; }
0
[ "CWE-416" ]
linux
6377f787aeb945cae7abbb6474798de129e1f3ac
41,455,027,930,106,950,000,000,000,000,000,000,000
16
appletalk: Fix use-after-free in atalk_proc_exit KASAN report this: BUG: KASAN: use-after-free in pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71 Read of size 8 at addr ffff8881f41fe5b0 by task syz-executor.0/2806 CPU: 0 PID: 2806 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45 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 pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71 remove_proc_entry+0xe8/0x420 fs/proc/generic.c:667 atalk_proc_exit+0x18/0x820 [appletalk] atalk_exit+0xf/0x5a [appletalk] __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:00007fb2de6b9c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200001c0 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb2de6ba6bc R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff Allocated by task 2806: set_track mm/kasan/common.c:85 [inline] __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:496 slab_post_alloc_hook mm/slab.h:444 [inline] slab_alloc_node mm/slub.c:2739 [inline] slab_alloc mm/slub.c:2747 [inline] kmem_cache_alloc+0xcf/0x250 mm/slub.c:2752 kmem_cache_zalloc include/linux/slab.h:730 [inline] __proc_create+0x30f/0xa20 fs/proc/generic.c:408 proc_mkdir_data+0x47/0x190 fs/proc/generic.c:469 0xffffffffc10c01bb 0xffffffffc10c0166 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 2806: set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:458 slab_free_hook mm/slub.c:1409 [inline] slab_free_freelist_hook mm/slub.c:1436 [inline] slab_free mm/slub.c:2986 [inline] kmem_cache_free+0xa6/0x2a0 mm/slub.c:3002 pde_put+0x6e/0x80 fs/proc/generic.c:647 remove_proc_entry+0x1d3/0x420 fs/proc/generic.c:684 0xffffffffc10c031c 0xffffffffc10c0166 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 ffff8881f41fe500 which belongs to the cache proc_dir_entry of size 256 The buggy address is located 176 bytes inside of 256-byte region [ffff8881f41fe500, ffff8881f41fe600) The buggy address belongs to the page: page:ffffea0007d07f80 count:1 mapcount:0 mapping:ffff8881f6e69a00 index:0x0 flags: 0x2fffc0000000200(slab) raw: 02fffc0000000200 dead000000000100 dead000000000200 ffff8881f6e69a00 raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881f41fe480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc ffff8881f41fe500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881f41fe580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881f41fe600: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ffff8881f41fe680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb It should check the return value of atalk_proc_init fails, otherwise atalk_exit will trgger use-after-free in pde_subdir_find while unload the module.This patch fix error cleanup path of atalk_init Reported-by: Hulk Robot <[email protected]> Signed-off-by: YueHaibing <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static RBinSymbol *__get_symbol(r_bin_le_obj_t *bin, ut64 *offset) { RBinSymbol *sym = R_NEW0 (RBinSymbol); if (!sym) { return NULL; } char *name = __read_nonnull_str_at (bin->buf, offset); if (!name) { r_bin_symbol_free (sym); return NULL; } sym->name = name; ut16 entry_idx = r_buf_read_le16_at (bin->buf, *offset); *offset += 2; sym->ordinal = entry_idx; return sym; }
0
[ "CWE-252" ]
radare2
d7ea20fb2e1433ebece9f004d87ad8f2377af23d
223,823,553,509,639,300,000,000,000,000,000,000,000
16
Fix #18923 - Fix resource exhaustion bug in LE binary (#18926)
njs_generate_export_statement_end(njs_vm_t *vm, njs_generator_t *generator, njs_parser_node_t *node) { njs_parser_node_t *obj; njs_vmcode_return_t *code; obj = node->right; njs_generate_code(generator, njs_vmcode_return_t, code, NJS_VMCODE_RETURN, 1, NULL); code->retval = obj->index; node->index = obj->index; return njs_generator_stack_pop(vm, generator, NULL); }
0
[ "CWE-703", "CWE-754" ]
njs
404553896792b8f5f429dc8852d15784a59d8d3e
292,358,278,792,345,570,000,000,000,000,000,000,000
15
Fixed break instruction in a try-catch block. Previously, JUMP offset for a break instruction inside a try-catch block was not set to a correct offset during code generation when a return instruction was present in inner try-catch block. The fix is to update the JUMP offset appropriately. This closes #553 issue on Github.
static const char *GetLocaleMonitorMessage(const char *text) { char message[MagickPathExtent], tag[MagickPathExtent]; const char *locale_message; register char *p; (void) CopyMagickString(tag,text,MagickPathExtent); p=strrchr(tag,'/'); if (p != (char *) NULL) *p='\0'; (void) FormatLocaleString(message,MagickPathExtent,"Monitor/%s",tag); locale_message=GetLocaleMessage(message); if (locale_message == message) return(text); return(locale_message); }
0
[]
ImageMagick
f391a5f4554fe47eb56d6277ac32d1f698572f0e
331,792,692,331,380,640,000,000,000,000,000,000,000
22
https://github.com/ImageMagick/ImageMagick/issues/1531
PHP_FUNCTION(xsl_xsltprocessor_remove_parameter) { zval *id; int name_len = 0, namespace_len = 0; char *name, *namespace; xsl_object *intern; DOM_GET_THIS(id); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &namespace, &namespace_len, &name, &name_len) == FAILURE) { RETURN_FALSE; } intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); if ( zend_hash_del(intern->parameter, name, name_len + 1) == SUCCESS) { RETURN_TRUE; } else { RETURN_FALSE; } }
0
[]
php-src
1744be2d17befc69bf00033993f4081852a747d6
83,362,253,309,822,340,000,000,000,000,000,000,000
19
Fix for bug #69782
static void log_cachehdr(const char *name, const char *contents, void *rock) { struct buf *buf = (struct buf *) rock; /* Ignore private headers in our cache */ if (name[0] == ':') return; buf_printf(buf, "%c%s: ", toupper(name[0]), name+1); if (!strcmp(name, "authorization")) { /* Replace authorization credentials with an ellipsis */ const char *creds = strchr(contents, ' ') + 1; buf_printf(buf, "%.*s%-*s\r\n", (int) (creds - contents), contents, (int) strlen(creds), "..."); } else buf_printf(buf, "%s\r\n", contents); }
0
[ "CWE-787" ]
cyrus-imapd
a5779db8163b99463e25e7c476f9cbba438b65f3
61,848,305,590,311,910,000,000,000,000,000,000,000
16
HTTP: don't overrun buffer when parsing strings with sscanf()
pthread_handler_t run_task(void *p) { ulonglong counter= 0, queries; ulonglong detach_counter; unsigned int commit_counter; MYSQL *mysql; MYSQL_RES *result; MYSQL_ROW row; statement *ptr; thread_context *con= (thread_context *)p; DBUG_ENTER("run_task"); DBUG_PRINT("info", ("task script \"%s\"", con->stmt ? con->stmt->string : "")); pthread_mutex_lock(&sleeper_mutex); while (master_wakeup) { pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); } pthread_mutex_unlock(&sleeper_mutex); if (!(mysql= mysql_init(NULL))) { fprintf(stderr,"%s: mysql_init() failed ERROR : %s\n", my_progname, mysql_error(mysql)); exit(0); } if (mysql_thread_init()) { fprintf(stderr,"%s: mysql_thread_init() failed ERROR : %s\n", my_progname, mysql_error(mysql)); exit(0); } DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user)); if (!opt_only_print) { if (slap_connect(mysql)) goto end; } DBUG_PRINT("info", ("connected.")); if (verbose >= 3) printf("connected!\n"); queries= 0; commit_counter= 0; if (commit_rate) run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0")); limit_not_met: for (ptr= con->stmt, detach_counter= 0; ptr && ptr->length; ptr= ptr->next, detach_counter++) { if (!opt_only_print && detach_rate && !(detach_counter % detach_rate)) { mysql_close(mysql); if (!(mysql= mysql_init(NULL))) { fprintf(stderr,"%s: mysql_init() failed ERROR : %s\n", my_progname, mysql_error(mysql)); exit(0); } if (slap_connect(mysql)) goto end; } /* We have to execute differently based on query type. This should become a function. */ if ((ptr->type == UPDATE_TYPE_REQUIRES_PREFIX) || (ptr->type == SELECT_TYPE_REQUIRES_PREFIX)) { int length; unsigned int key_val; char *key; char buffer[HUGE_STRING_LENGTH]; /* This should only happen if some sort of new engine was implemented that didn't properly handle UPDATEs. Just in case someone runs this under an experimental engine we don't want a crash so the if() is placed here. */ DBUG_ASSERT(primary_keys_number_of); if (primary_keys_number_of) { key_val= (unsigned int)(random() % primary_keys_number_of); key= primary_keys[key_val]; DBUG_ASSERT(key); length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'", (int)ptr->length, ptr->string, key); if (run_query(mysql, buffer, length)) { fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", my_progname, (uint)length, buffer, mysql_error(mysql)); exit(0); } } } else { if (run_query(mysql, ptr->string, ptr->length)) { fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n", my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql)); exit(0); } } do { if (mysql_field_count(mysql)) { if (!(result= mysql_store_result(mysql))) fprintf(stderr, "%s: Error when storing result: %d %s\n", my_progname, mysql_errno(mysql), mysql_error(mysql)); else { while ((row= mysql_fetch_row(result))) counter++; mysql_free_result(result); } } } while(mysql_next_result(mysql) == 0); queries++; if (commit_rate && (++commit_counter == commit_rate)) { commit_counter= 0; run_query(mysql, "COMMIT", strlen("COMMIT")); } if (con->limit && queries == con->limit) goto end; } if (con->limit && queries < con->limit) goto limit_not_met; end: if (commit_rate) run_query(mysql, "COMMIT", strlen("COMMIT")); if (!opt_only_print) mysql_close(mysql); mysql_thread_end(); pthread_mutex_lock(&counter_mutex); thread_counter--; pthread_cond_signal(&count_threshhold); pthread_mutex_unlock(&counter_mutex); DBUG_RETURN(0); }
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
319,415,906,878,815,800,000,000,000,000,000,000,000
165
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
R_API char *r_bin_java_print_utf8_cp_stringify(RBinJavaCPTypeObj *obj) { ut32 size = 255, consumed = 0; char *utf8_str = r_hex_bin2strdup (obj->info.cp_utf8.bytes, obj->info.cp_utf8.length); char *value = malloc (size + strlen (utf8_str)); if (value) { memset (value, 0, size); consumed = snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d.%s", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_utf8.length, utf8_str); if (consumed >= size - 1) { free (value); size += size >> 1; value = malloc (size + strlen (utf8_str)); if (value) { memset (value, 0, size); consumed = snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d.%s", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_utf8.length, utf8_str); } } } free (utf8_str); return value; }
0
[ "CWE-125" ]
radare2
e9ce0d64faf19fa4e9c260250fbdf25e3c11e152
326,702,641,403,483,350,000,000,000,000,000,000,000
26
Fix #10498 - Fix crash in fuzzed java files (#10511)
int data() const { return data_id_; }
0
[ "CWE-703", "CWE-787" ]
tensorflow
204945b19e44b57906c9344c0d00120eeeae178a
317,872,783,463,454,300,000,000,000,000,000,000,000
1
[tflite] Validate segment ids for segment_sum. Segment identifiers in segment_sum should be in a 1-D tensor of same size as the first dimension of the input. The values of the tensor should be integers from {0, 1, 2, ... k-1}, where k is the first dimension of the input. The segment identifiers must not contain jumps and must be increasing. See https://www.tensorflow.org/api_docs/python/tf/math#Segmentation as the source for these constraints. PiperOrigin-RevId: 332510942 Change-Id: I898beaba00642c918bcd4b4d4ce893ebb190d869
GPMF_ERR GPMF_ScaledData(GPMF_stream *ms, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples, GPMF_SampleType outputType) { if (ms && buffer) { uint8_t *data = (uint8_t *)&ms->buffer[ms->pos + 2]; uint8_t *output = (uint8_t *)buffer; uint32_t sample_size = GPMF_SAMPLE_SIZE(ms->buffer[ms->pos + 1]); uint32_t output_sample_size = GPMF_SizeofType(outputType); uint32_t remaining_sample_size = GPMF_DATA_PACKEDSIZE(ms->buffer[ms->pos + 1]); uint8_t type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]); char complextype[64] = "L"; uint32_t inputtypesize = 0; uint32_t inputtypeelements = 0; uint8_t scaletype = 0; uint8_t scalecount = 0; uint32_t scaletypesize = 0; uint32_t *scaledata = NULL; uint32_t tmpbuffer[64]; uint32_t tmpbuffersize = sizeof(tmpbuffer); uint32_t elements = 1; type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]); if (type == GPMF_TYPE_NEST) return GPMF_ERROR_MEMORY; if (GPMF_OK != IsValidSize(ms, remaining_sample_size >> 2)) return GPMF_ERROR_BAD_STRUCTURE; remaining_sample_size -= sample_offset * sample_size; // skip samples data += sample_offset * sample_size; if (remaining_sample_size < sample_size * read_samples) return GPMF_ERROR_MEMORY; if (type == GPMF_TYPE_COMPLEX) { GPMF_stream find_stream; GPMF_CopyState(ms, &find_stream); if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TYPE, GPMF_RECURSE_LEVELS)) { char *data1 = (char *)GPMF_RawData(&find_stream); int size = GPMF_RawDataSize(&find_stream); uint32_t typestringlength = sizeof(complextype); if (GPMF_OK == GPMF_ExpandComplexTYPE(data1, size, complextype, &typestringlength)) { inputtypeelements = elements = typestringlength; if (sample_size != GPMF_SizeOfComplexTYPE(complextype, typestringlength)) return GPMF_ERROR_TYPE_NOT_SUPPORTED; } else return GPMF_ERROR_TYPE_NOT_SUPPORTED; } else return GPMF_ERROR_TYPE_NOT_SUPPORTED; } else { complextype[0] = type; inputtypesize = GPMF_SizeofType(type); if (inputtypesize == 0) return GPMF_ERROR_MEMORY; inputtypeelements = 1; elements = sample_size / inputtypesize; } if (output_sample_size * elements * read_samples > buffersize) return GPMF_ERROR_MEMORY; switch (outputType) { case GPMF_TYPE_SIGNED_BYTE: case GPMF_TYPE_UNSIGNED_BYTE: case GPMF_TYPE_SIGNED_SHORT: case GPMF_TYPE_UNSIGNED_SHORT: case GPMF_TYPE_FLOAT: case GPMF_TYPE_SIGNED_LONG: case GPMF_TYPE_UNSIGNED_LONG: case GPMF_TYPE_DOUBLE: // All supported formats. { GPMF_stream fs; GPMF_CopyState(ms, &fs); if (GPMF_OK == GPMF_FindPrev(&fs, GPMF_KEY_SCALE, GPMF_CURRENT_LEVEL)) { scaledata = (uint32_t *)GPMF_RawData(&fs); scaletype = GPMF_SAMPLE_TYPE(fs.buffer[fs.pos + 1]); switch (scaletype) { case GPMF_TYPE_SIGNED_BYTE: case GPMF_TYPE_UNSIGNED_BYTE: case GPMF_TYPE_SIGNED_SHORT: case GPMF_TYPE_UNSIGNED_SHORT: case GPMF_TYPE_SIGNED_LONG: case GPMF_TYPE_UNSIGNED_LONG: case GPMF_TYPE_FLOAT: scalecount = GPMF_SAMPLES(fs.buffer[fs.pos + 1]); scaletypesize = GPMF_SizeofType(scaletype); if (scalecount > 1) if (scalecount != elements) return GPMF_ERROR_SCALE_COUNT; GPMF_FormattedData(&fs, tmpbuffer, tmpbuffersize, 0, scalecount); scaledata = (uint32_t *)tmpbuffer; break; default: return GPMF_ERROR_TYPE_NOT_SUPPORTED; break; } } else { scaletype = 'L'; scalecount = 1; tmpbuffer[0] = 1; // set the scale to 1 is no scale was provided scaledata = (uint32_t *)tmpbuffer; } } while (read_samples--) { uint32_t i; uint8_t *scaledata8 = (uint8_t *)scaledata; for (i = 0; i < elements; i++) { switch (complextype[i % inputtypeelements]) { case GPMF_TYPE_FLOAT: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, float, uint32_t) break; case GPMF_TYPE_SIGNED_BYTE: MACRO_BSWAP_CAST_SCALE(NOSWAP8, int8_t, uint8_t) break; case GPMF_TYPE_UNSIGNED_BYTE: MACRO_BSWAP_CAST_SCALE(NOSWAP8, uint8_t, uint8_t) break; case GPMF_TYPE_SIGNED_SHORT: MACRO_BSWAP_CAST_SCALE(BYTESWAP16, int16_t, uint16_t) break; case GPMF_TYPE_UNSIGNED_SHORT: MACRO_BSWAP_CAST_SCALE(BYTESWAP16, uint16_t, uint16_t) break; case GPMF_TYPE_SIGNED_LONG: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, int32_t, uint32_t) break; case GPMF_TYPE_UNSIGNED_LONG: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, uint32_t, uint32_t) break; case GPMF_TYPE_SIGNED_64BIT_INT: MACRO_BSWAP_CAST_SCALE(BYTESWAP64, uint64_t, uint64_t) break; case GPMF_TYPE_UNSIGNED_64BIT_INT: MACRO_BSWAP_CAST_SCALE(BYTESWAP64, uint64_t, uint64_t) break; default: return GPMF_ERROR_TYPE_NOT_SUPPORTED; break; } if (scalecount > 1) scaledata8 += scaletypesize; } } break; default: return GPMF_ERROR_TYPE_NOT_SUPPORTED; break; } return GPMF_OK; } return GPMF_ERROR_MEMORY; }
0
[ "CWE-125", "CWE-369", "CWE-787" ]
gpmf-parser
341f12cd5b97ab419e53853ca00176457c9f1681
76,778,470,977,098,960,000,000,000,000,000,000,000
164
fixed many security issues with the too crude mp4 reader
_xfs_dic2xflags( __uint16_t di_flags) { uint flags = 0; if (di_flags & XFS_DIFLAG_ANY) { if (di_flags & XFS_DIFLAG_REALTIME) flags |= XFS_XFLAG_REALTIME; if (di_flags & XFS_DIFLAG_PREALLOC) flags |= XFS_XFLAG_PREALLOC; if (di_flags & XFS_DIFLAG_IMMUTABLE) flags |= XFS_XFLAG_IMMUTABLE; if (di_flags & XFS_DIFLAG_APPEND) flags |= XFS_XFLAG_APPEND; if (di_flags & XFS_DIFLAG_SYNC) flags |= XFS_XFLAG_SYNC; if (di_flags & XFS_DIFLAG_NOATIME) flags |= XFS_XFLAG_NOATIME; if (di_flags & XFS_DIFLAG_NODUMP) flags |= XFS_XFLAG_NODUMP; if (di_flags & XFS_DIFLAG_RTINHERIT) flags |= XFS_XFLAG_RTINHERIT; if (di_flags & XFS_DIFLAG_PROJINHERIT) flags |= XFS_XFLAG_PROJINHERIT; if (di_flags & XFS_DIFLAG_NOSYMLINKS) flags |= XFS_XFLAG_NOSYMLINKS; if (di_flags & XFS_DIFLAG_EXTSIZE) flags |= XFS_XFLAG_EXTSIZE; if (di_flags & XFS_DIFLAG_EXTSZINHERIT) flags |= XFS_XFLAG_EXTSZINHERIT; if (di_flags & XFS_DIFLAG_NODEFRAG) flags |= XFS_XFLAG_NODEFRAG; if (di_flags & XFS_DIFLAG_FILESTREAM) flags |= XFS_XFLAG_FILESTREAM; } return flags; }
0
[ "CWE-19" ]
linux
fc0561cefc04e7803c0f6501ca4f310a502f65b8
334,328,965,725,422,020,000,000,000,000,000,000,000
38
xfs: optimise away log forces on timestamp updates for fdatasync xfs: timestamp updates cause excessive fdatasync log traffic Sage Weil reported that a ceph test workload was writing to the log on every fdatasync during an overwrite workload. Event tracing showed that the only metadata modification being made was the timestamp updates during the write(2) syscall, but fdatasync(2) is supposed to ignore them. The key observation was that the transactions in the log all looked like this: INODE: #regs: 4 ino: 0x8b flags: 0x45 dsize: 32 And contained a flags field of 0x45 or 0x85, and had data and attribute forks following the inode core. This means that the timestamp updates were triggering dirty relogging of previously logged parts of the inode that hadn't yet been flushed back to disk. There are two parts to this problem. The first is that XFS relogs dirty regions in subsequent transactions, so it carries around the fields that have been dirtied since the last time the inode was written back to disk, not since the last time the inode was forced into the log. The second part is that on v5 filesystems, the inode change count update during inode dirtying also sets the XFS_ILOG_CORE flag, so on v5 filesystems this makes a timestamp update dirty the entire inode. As a result when fdatasync is run, it looks at the dirty fields in the inode, and sees more than just the timestamp flag, even though the only metadata change since the last fdatasync was just the timestamps. Hence we force the log on every subsequent fdatasync even though it is not needed. To fix this, add a new field to the inode log item that tracks changes since the last time fsync/fdatasync forced the log to flush the changes to the journal. This flag is updated when we dirty the inode, but we do it before updating the change count so it does not carry the "core dirty" flag from timestamp updates. The fields are zeroed when the inode is marked clean (due to writeback/freeing) or when an fsync/datasync forces the log. Hence if we only dirty the timestamps on the inode between fsync/fdatasync calls, the fdatasync will not trigger another log force. Over 100 runs of the test program: Ext4 baseline: runtime: 1.63s +/- 0.24s avg lat: 1.59ms +/- 0.24ms iops: ~2000 XFS, vanilla kernel: runtime: 2.45s +/- 0.18s avg lat: 2.39ms +/- 0.18ms log forces: ~400/s iops: ~1000 XFS, patched kernel: runtime: 1.49s +/- 0.26s avg lat: 1.46ms +/- 0.25ms log forces: ~30/s iops: ~1500 Reported-by: Sage Weil <[email protected]> Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Brian Foster <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
int iscsi_login_tx_data( struct iscsi_conn *conn, char *pdu_buf, char *text_buf, int text_length) { int length, tx_sent, iov_cnt = 1; struct kvec iov[2]; length = (ISCSI_HDR_LEN + text_length); memset(&iov[0], 0, 2 * sizeof(struct kvec)); iov[0].iov_len = ISCSI_HDR_LEN; iov[0].iov_base = pdu_buf; if (text_buf && text_length) { iov[1].iov_len = text_length; iov[1].iov_base = text_buf; iov_cnt++; } /* * Initial Marker-less Interval. * Add the values regardless of IFMarker/OFMarker, considering * it may not be negoitated yet. */ conn->if_marker += length; tx_sent = tx_data(conn, &iov[0], iov_cnt, length); if (tx_sent != length) { pr_err("tx_data returned %d, expecting %d.\n", tx_sent, length); return -1; } return 0; }
0
[ "CWE-119" ]
target-pending
cea4dcfdad926a27a18e188720efe0f2c9403456
243,128,360,181,628,070,000,000,000,000,000,000,000
37
iscsi-target: fix heap buffer overflow on error If a key was larger than 64 bytes, as checked by iscsi_check_key(), the error response packet, generated by iscsi_add_notunderstood_response(), would still attempt to copy the entire key into the packet, overflowing the structure on the heap. Remote preauthentication kernel memory corruption was possible if a target was configured and listening on the network. CVE-2013-2850 Signed-off-by: Kees Cook <[email protected]> Cc: [email protected] Signed-off-by: Nicholas Bellinger <[email protected]>
long CurlIo::CurlImpl::getFileLength() { curl_easy_reset(curl_); // reset all options std::string response; curl_easy_setopt(curl_, CURLOPT_URL, path_.c_str()); curl_easy_setopt(curl_, CURLOPT_NOBODY, 1); // HEAD curl_easy_setopt(curl_, CURLOPT_WRITEFUNCTION, curlWriter); curl_easy_setopt(curl_, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl_, CURLOPT_CONNECTTIMEOUT, timeout_); //curl_easy_setopt(curl_, CURLOPT_VERBOSE, 1); // debugging mode /* Perform the request, res will get the return code */ CURLcode res = curl_easy_perform(curl_); if(res != CURLE_OK) { // error happends throw Error(kerErrorMessage, curl_easy_strerror(res)); } // get return code long returnCode; curl_easy_getinfo (curl_, CURLINFO_RESPONSE_CODE, &returnCode); // get code if (returnCode >= 400 || returnCode < 0) { throw Error(kerTiffDirectoryTooLarge, "Server", returnCode); } // get length double temp; curl_easy_getinfo(curl_, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &temp); // return -1 if unknown return (long) temp; }
0
[ "CWE-190" ]
exiv2
c73d1e27198a389ce7caf52ac30f8e2120acdafd
305,771,789,139,972,300,000,000,000,000,000,000,000
29
Avoid negative integer overflow when `filesize < io_->tell()`. This fixes #791.
e_ews_connection_get_oal_detail_sync (EEwsConnection *cnc, const gchar *oal_id, const gchar *oal_element, const gchar *old_etag, GSList **elements, gchar **etag, GCancellable *cancellable, GError **error) { EAsyncClosure *closure; GAsyncResult *result; gboolean success; g_return_val_if_fail (E_IS_EWS_CONNECTION (cnc), FALSE); closure = e_async_closure_new (); e_ews_connection_get_oal_detail ( cnc, oal_id, oal_element, old_etag, cancellable, e_async_closure_callback, closure); result = e_async_closure_wait (closure); success = e_ews_connection_get_oal_detail_finish ( cnc, result, elements, etag, error); e_async_closure_free (closure); return success; }
0
[ "CWE-295" ]
evolution-ews
915226eca9454b8b3e5adb6f2fff9698451778de
294,539,480,980,971,380,000,000,000,000,000,000,000
30
I#27 - SSL Certificates are not validated This depends on https://gitlab.gnome.org/GNOME/evolution-data-server/commit/6672b8236139bd6ef41ecb915f4c72e2a052dba5 too. Closes https://gitlab.gnome.org/GNOME/evolution-ews/issues/27
Status DoCompute(OpKernelContext* ctx) { tensorflow::ResourceTagger tag(kTFDataResourceTag, ctx->op_kernel().type_string()); tstring filename; TF_RETURN_IF_ERROR( ParseScalarArgument<tstring>(ctx, "filename", &filename)); tstring compression_type; TF_RETURN_IF_ERROR(ParseScalarArgument<tstring>(ctx, "compression_type", &compression_type)); std::unique_ptr<WritableFile> file; TF_RETURN_IF_ERROR(ctx->env()->NewWritableFile(filename, &file)); auto writer = absl::make_unique<io::RecordWriter>( file.get(), io::RecordWriterOptions::CreateRecordWriterOptions(compression_type)); DatasetBase* dataset; TF_RETURN_IF_ERROR(GetDatasetFromVariantTensor(ctx->input(0), &dataset)); IteratorContext::Params params(ctx); FunctionHandleCache function_handle_cache(params.flr); params.function_handle_cache = &function_handle_cache; ResourceMgr resource_mgr; params.resource_mgr = &resource_mgr; CancellationManager cancellation_manager(ctx->cancellation_manager()); params.cancellation_manager = &cancellation_manager; IteratorContext iter_ctx(std::move(params)); DatasetBase* finalized_dataset; TF_RETURN_IF_ERROR(FinalizeDataset(ctx, dataset, &finalized_dataset)); std::unique_ptr<IteratorBase> iterator; TF_RETURN_IF_ERROR(finalized_dataset->MakeIterator( &iter_ctx, /*parent=*/nullptr, "ToTFRecordOpIterator", &iterator)); std::vector<Tensor> components; components.reserve(finalized_dataset->output_dtypes().size()); bool end_of_sequence; do { TF_RETURN_IF_ERROR( iterator->GetNext(&iter_ctx, &components, &end_of_sequence)); if (!end_of_sequence) { TF_RETURN_IF_ERROR( writer->WriteRecord(components[0].scalar<tstring>()())); } components.clear(); } while (!end_of_sequence); return Status::OK(); }
1
[ "CWE-787" ]
tensorflow
e0b6e58c328059829c3eb968136f17aa72b6c876
287,219,125,866,827,770,000,000,000,000,000,000,000
49
Fix segfault/heap buffer overflow in `{Experimental,}DatasetToTFRecord` where dataset is numeric. Code assumes only strings inputs and then interprets numbers as valid `tstring`s. Then, when trying to compute the CRC of the record this results in heap buffer overflow. PiperOrigin-RevId: 387675909 Change-Id: I7396b9b8afc1ac744112af7c0b1cd7bb41e0f556
static void mctp_serial_push_trailer(struct mctp_serial *dev, unsigned char c) { switch (dev->rxpos) { case 0: dev->rxfcs_rcvd = c << 8; dev->rxpos++; break; case 1: dev->rxfcs_rcvd |= c; dev->rxpos++; break; case 2: if (c != BYTE_FRAME) { dev->rxstate = STATE_ERR; } else { mctp_serial_rx(dev); dev->rxlen = 0; dev->rxpos = 0; dev->rxstate = STATE_IDLE; } break; } }
0
[]
linux
6c342ce2239c182c2428ce5a44cb32330434ae6e
100,091,140,472,507,950,000,000,000,000,000,000,000
23
mctp: serial: Cancel pending work from ndo_uninit handler We cannot do the cancel_work_sync from after the unregister_netdev, as the dev pointer is no longer valid, causing a uaf on ldisc unregister (or device close). Instead, do the cancel_work_sync from the ndo_uninit op, where the dev still exists, but the queue has stopped. Fixes: 7bd9890f3d74 ("mctp: serial: cancel tx work on ldisc close") Reported-by: Luo Likang <[email protected]> Tested-by: Luo Likang <[email protected]> Signed-off-by: Jeremy Kerr <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
do_dump_fpu (struct unw_frame_info *info, void *arg) { do_dump_task_fpu(current, info, arg); }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
337,259,486,328,432,700,000,000,000,000,000,000,000
4
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
search_duplicated_node (const re_dfa_t *dfa, Idx org_node, unsigned int constraint) { Idx idx; for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) { if (org_node == dfa->org_indices[idx] && constraint == dfa->nodes[idx].constraint) return idx; /* Found. */ } return REG_MISSING; /* Not found. */ }
0
[ "CWE-19" ]
gnulib
5513b40999149090987a0341c018d05d3eea1272
43,628,292,250,796,070,000,000,000,000,000,000,000
12
Diagnose ERE '()|\1' Problem reported by Hanno Böck in: http://bugs.gnu.org/21513 * lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep track of the set of previously-completed subexpressions available before the first alternative, and restore this set just before parsing each subsequent alternative. This lets us diagnose the invalid back-reference in the ERE '()|\1'.
static inline int joinable_pair(NM a, NM b) { return( /* nets have the same mask */ u128_cmp(a->mask, b->mask) == 0 && /* but are distinct */ u128_cmp(a->neta, b->neta) != 0 && /* and would both be subsets of the same mask << 1 */ u128_cmp(u128_lit(0, 0), u128_and( u128_xor(a->neta, b->neta), u128_lsh(a->mask, 1) )) == 0 ); }
0
[]
netmask
29a9c239bd1008363f5b34ffd6c2cef906f3660c
304,151,748,723,096,070,000,000,000,000,000,000,000
13
bump version to 2.4.4 * remove checks for negative unsigned ints, fixes #2 * harden error logging functions, fixes #3
static struct nft_hook *nft_hook_list_find(struct list_head *hook_list, const struct nft_hook *this) { struct nft_hook *hook; list_for_each_entry(hook, hook_list, list) { if (this->ops.dev == hook->ops.dev) return hook; } return NULL; }
0
[ "CWE-665" ]
linux
ad9f151e560b016b6ad3280b48e42fa11e1a5440
289,685,197,054,462,040,000,000,000,000,000,000,000
12
netfilter: nf_tables: initialize set before expression setup nft_set_elem_expr_alloc() needs an initialized set if expression sets on the NFT_EXPR_GC flag. Move set fields initialization before expression setup. [4512935.019450] ================================================================== [4512935.019456] BUG: KASAN: null-ptr-deref in nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables] [4512935.019487] Read of size 8 at addr 0000000000000070 by task nft/23532 [4512935.019494] CPU: 1 PID: 23532 Comm: nft Not tainted 5.12.0-rc4+ #48 [...] [4512935.019502] Call Trace: [4512935.019505] dump_stack+0x89/0xb4 [4512935.019512] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables] [4512935.019536] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables] [4512935.019560] kasan_report.cold.12+0x5f/0xd8 [4512935.019566] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables] [4512935.019590] nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables] [4512935.019615] nf_tables_newset+0xc7f/0x1460 [nf_tables] Reported-by: [email protected] Fixes: 65038428b2c6 ("netfilter: nf_tables: allow to specify stateful expression in set definition") Signed-off-by: Pablo Neira Ayuso <[email protected]>
void jpc_enc_cp_destroy(jpc_enc_cp_t *cp) { if (cp->ccps) { if (cp->tcp.ilyrrates) { jas_free(cp->tcp.ilyrrates); } jas_free(cp->ccps); } jas_free(cp); }
0
[ "CWE-189" ]
jasper
3c55b399c36ef46befcb21e4ebc4799367f89684
47,683,186,448,406,710,000,000,000,000,000,000,000
10
At many places in the code, jas_malloc or jas_recalloc was being invoked with the size argument being computed in a manner that would not allow integer overflow to be detected. Now, these places in the code have been modified to use special-purpose memory allocation functions (e.g., jas_alloc2, jas_alloc3, jas_realloc2) that check for overflow. This should fix many security problems.
TEST_F(OptimizePipeline, MultipleMatchesPushedDown) { auto unpack = fromjson( "{$_internalUnpackBucket: { exclude: [], timeField: 'time', metaField: 'myMeta', " "bucketMaxSpanSeconds: 3600}}"); auto pipeline = Pipeline::parse(makeVector(unpack, fromjson("{$match: {myMeta: {$gte: 0, $lte: 5}}}"), fromjson("{$match: {a: {$lte: 4}}}")), getExpCtx()); ASSERT_EQ(3u, pipeline->getSources().size()); pipeline->optimizePipeline(); // We should push down both the $match on the metaField and the predicates on the control field. // The created $match stages should be added before $_internalUnpackBucket and merged. auto stages = pipeline->writeExplainOps(ExplainOptions::Verbosity::kQueryPlanner); ASSERT_EQ(3u, stages.size()); ASSERT_BSONOBJ_EQ(fromjson("{$match: {$and: [{meta: {$gte: 0}}, {meta: {$lte: 5}}, " "{'control.min.a': {$_internalExprLte: 4}}]}}"), stages[0].getDocument().toBson()); ASSERT_BSONOBJ_EQ(unpack, stages[1].getDocument().toBson()); ASSERT_BSONOBJ_EQ(fromjson("{$match: {a: {$lte: 4}}}"), stages[2].getDocument().toBson()); }
0
[]
mongo
b3107d73a2c58d7e016b834dae0acfd01c0db8d7
299,021,804,779,577,550,000,000,000,000,000,000,000
22
SERVER-59299: Flatten top-level nested $match stages in doOptimizeAt (cherry picked from commit 4db5eceda2cff697f35c84cd08232bac8c33beec)
parse_OUTPUT_REG(const char *arg, struct ofpbuf *ofpacts, enum ofputil_protocol *usable_protocols OVS_UNUSED) { return parse_OUTPUT(arg, ofpacts, usable_protocols); }
0
[ "CWE-125" ]
ovs
9237a63c47bd314b807cda0bd2216264e82edbe8
162,141,540,543,410,470,000,000,000,000,000,000,000
5
ofp-actions: Avoid buffer overread in BUNDLE action decoding. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9052 Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Justin Pettit <[email protected]>
DECLAREcpFunc(cpSeparateStrips2ContigTiles) { return cpImage(in, out, readSeparateStripsIntoBuffer, writeBufferToContigTiles, imagelength, imagewidth, spp); }
0
[ "CWE-190" ]
libtiff
43c0b81a818640429317c80fea1e66771e85024b
28,474,861,850,704,890,000,000,000,000,000,000,000
7
* tools/tiffcp.c: fix read of undefined variable in case of missing required tags. Found on test case of MSVR 35100. * tools/tiffcrop.c: fix read of undefined buffer in readContigStripsIntoBuffer() due to uint16 overflow. Probably not a security issue but I can be wrong. Reported as MSVR 35100 by Axel Souchet from the MSRC Vulnerabilities & Mitigations team.
free_sequence_of(const struct atype_info *eltinfo, void *val, size_t count) { void *eltptr; assert(eltinfo->size != 0); while (count-- > 0) { eltptr = (char *)val + count * eltinfo->size; free_atype(eltinfo, eltptr); free_atype_ptr(eltinfo, eltptr); } }
0
[ "CWE-674", "CWE-787" ]
krb5
57415dda6cf04e73ffc3723be518eddfae599bfd
292,178,830,842,383,400,000,000,000,000,000,000,000
11
Add recursion limit for ASN.1 indefinite lengths The libkrb5 ASN.1 decoder supports BER indefinite lengths. It computes the tag length using recursion; the lack of a recursion limit allows an attacker to overrun the stack and cause the process to crash. Reported by Demi Obenour. CVE-2020-28196: In MIT krb5 releases 1.11 and later, an unauthenticated attacker can cause a denial of service for any client or server to which it can send an ASN.1-encoded Kerberos message of sufficient length. ticket: 8959 (new) tags: pullup target_version: 1.18-next target_version: 1.17-next
static inline u16 ns_to_clock_divider(unsigned int ns) { return count_to_clock_divider( DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ / 1000000 * ns, 1000)); }
0
[ "CWE-400", "CWE-401" ]
linux
a7b2df76b42bdd026e3106cf2ba97db41345a177
263,699,570,708,255,120,000,000,000,000,000,000,000
5
media: rc: prevent memory leak in cx23888_ir_probe In cx23888_ir_probe if kfifo_alloc fails the allocated memory for state should be released. Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: Sean Young <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
static void mm_init_aio(struct mm_struct *mm) { #ifdef CONFIG_AIO spin_lock_init(&mm->ioctx_lock); INIT_HLIST_HEAD(&mm->ioctx_list); #endif }
0
[ "CWE-20" ]
linux
f106eee10038c2ee5b6056aaf3f6d5229be6dcdd
136,946,901,184,707,400,000,000,000,000,000,000,000
7
pids: fix fork_idle() to setup ->pids correctly copy_process(pid => &init_struct_pid) doesn't do attach_pid/etc. It shouldn't, but this means that the idle threads run with the wrong pids copied from the caller's task_struct. In x86 case the caller is either kernel_init() thread or keventd. In particular, this means that after the series of cpu_up/cpu_down an idle thread (which never exits) can run with .pid pointing to nowhere. Change fork_idle() to initialize idle->pids[] correctly. We only set .pid = &init_struct_pid but do not add .node to list, INIT_TASK() does the same for the boot-cpu idle thread (swapper). Signed-off-by: Oleg Nesterov <[email protected]> Cc: Cedric Le Goater <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Eric Biederman <[email protected]> Cc: Herbert Poetzl <[email protected]> Cc: Mathias Krause <[email protected]> Acked-by: Roland McGrath <[email protected]> Acked-by: Serge Hallyn <[email protected]> Cc: Sukadev Bhattiprolu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void coeff_filter(double *coeff, int n, const double kernel[4]) { double prev1 = coeff[1], prev2 = coeff[2], prev3 = coeff[3]; for (int i = 0; i <= n; ++i) { double res = coeff[i + 0] * kernel[0] + (prev1 + coeff[i + 1]) * kernel[1] + (prev2 + coeff[i + 2]) * kernel[2] + (prev3 + coeff[i + 3]) * kernel[3]; prev3 = prev2; prev2 = prev1; prev1 = coeff[i]; coeff[i] = res; } }
0
[ "CWE-119", "CWE-787" ]
libass
08e754612019ed84d1db0d1fc4f5798248decd75
93,675,001,838,811,710,000,000,000,000,000,000,000
14
Fix blur coefficient calculation buffer overflow Found by fuzzer test case id:000082,sig:11,src:002579,op:havoc,rep:8. Correctness should be checked, but this fixes the overflow for good.
static RPrelinkRange *get_prelink_info_range_from_mach0(struct MACH0_(obj_t) *mach0) { struct section_t *sections = NULL; if (!(sections = MACH0_(get_sections) (mach0))) { return NULL; } RPrelinkRange *prelink_range = R_NEW0 (RPrelinkRange); if (!prelink_range) { R_FREE (sections); return NULL; } int incomplete = 3; int i = 0; for (; !sections[i].last; i++) { if (strstr (sections[i].name, "__PRELINK_INFO.__info")) { prelink_range->range.offset = sections[i].offset; prelink_range->range.size = sections[i].size; if (!--incomplete) { break; } } if (strstr (sections[i].name, "__PRELINK_TEXT.__text")) { prelink_range->pa2va_exec = sections[i].addr - sections[i].offset; if (!--incomplete) { break; } } if (strstr (sections[i].name, "__PRELINK_DATA.__data")) { prelink_range->pa2va_data = sections[i].addr - sections[i].offset; if (!--incomplete) { break; } } } R_FREE (sections); if (incomplete == 1 && !prelink_range->pa2va_data) { struct MACH0_(segment_command) *seg; int nsegs = R_MIN (mach0->nsegs, 128); size_t i; for (i = 0; i < nsegs; i++) { seg = &mach0->segs[i]; if (!strcmp (seg->segname, "__DATA")) { prelink_range->pa2va_data = seg->vmaddr - seg->fileoff; incomplete--; break; } } } if (incomplete) { R_FREE (prelink_range); } return prelink_range; }
0
[ "CWE-476" ]
radare2
feaa4e7f7399c51ee6f52deb84dc3f795b4035d6
174,931,006,540,810,940,000,000,000,000,000,000,000
60
Fix null deref in xnu.kernelcache ##crash * Reported by @xshad3 via huntr.dev
PackLinuxElf64::elf_unsigned_dynamic(unsigned int key) const { Elf64_Dyn const *dynp= dynseg; if (dynp) for (; (unsigned)((char const *)dynp - (char const *)dynseg) < sz_dynseg && Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) { return get_te64(&dynp->d_val); } return 0; }
0
[ "CWE-415" ]
upx
d9288213ec156dffc435566b9d393d23e87c6914
202,946,717,346,861,050,000,000,000,000,000,000,000
10
More checking of PT_DYNAMIC and its contents. https://github.com/upx/upx/issues/206 modified: p_lx_elf.cpp
iasecc_se_cache_info(struct sc_card *card, struct iasecc_se_info *se) { struct iasecc_private_data *prv = (struct iasecc_private_data *) card->drv_data; struct sc_context *ctx = card->ctx; struct iasecc_se_info *se_info = NULL, *si = NULL; int rv; LOG_FUNC_CALLED(ctx); se_info = calloc(1, sizeof(struct iasecc_se_info)); if (!se_info) LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "SE info allocation error"); memcpy(se_info, se, sizeof(struct iasecc_se_info)); if (card->cache.valid && card->cache.current_df) { sc_file_dup(&se_info->df, card->cache.current_df); if (se_info->df == NULL) { free(se_info); LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate current DF file"); } } rv = iasecc_docp_copy(ctx, &se->docp, &se_info->docp); if (rv < 0) { free(se_info->df); free(se_info); LOG_TEST_RET(ctx, rv, "Cannot make copy of DOCP"); } if (!prv->se_info) { prv->se_info = se_info; } else { for (si = prv->se_info; si->next; si = si->next) ; si->next = se_info; } LOG_FUNC_RETURN(ctx, rv); }
0
[ "CWE-125" ]
OpenSC
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
113,956,611,930,369,380,000,000,000,000,000,000,000
40
fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
static int acm_reset_resume(struct usb_interface *intf) { struct acm *acm = usb_get_intfdata(intf); if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) tty_port_tty_hangup(&acm->port, false); return acm_resume(intf); }
0
[ "CWE-703" ]
linux
8835ba4a39cf53f705417b3b3a94eb067673f2c9
21,371,766,341,550,230,000,000,000,000,000,000,000
9
USB: cdc-acm: more sanity checking An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices. Signed-off-by: Oliver Neukum <[email protected]> CC: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
mono_generic_param_is_constraint_compatible (VerifyContext *ctx, MonoGenericParam *target, MonoGenericParam *candidate, MonoClass *candidate_param_class, MonoGenericContext *context) { MonoGenericParamInfo *tinfo = mono_generic_param_info (target); MonoGenericParamInfo *cinfo = mono_generic_param_info (candidate); int tmask = tinfo->flags & GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK; int cmask = cinfo->flags & GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK; if ((tmask & cmask) != tmask) return FALSE; if (tinfo->constraints) { MonoClass **target_class, **candidate_class; for (target_class = tinfo->constraints; *target_class; ++target_class) { MonoClass *tc; MonoType *inflated = verifier_inflate_type (ctx, &(*target_class)->byval_arg, context); if (!inflated) return FALSE; tc = mono_class_from_mono_type (inflated); mono_metadata_free_type (inflated); /* * A constraint from @target might inflate into @candidate itself and in that case we don't need * check it's constraints since it satisfy the constraint by itself. */ if (mono_metadata_type_equal (&tc->byval_arg, &candidate_param_class->byval_arg)) continue; if (!cinfo->constraints) return FALSE; for (candidate_class = cinfo->constraints; *candidate_class; ++candidate_class) { MonoClass *cc; inflated = verifier_inflate_type (ctx, &(*candidate_class)->byval_arg, ctx->generic_context); if (!inflated) return FALSE; cc = mono_class_from_mono_type (inflated); mono_metadata_free_type (inflated); if (mono_class_is_assignable_from (tc, cc)) break; } if (!*candidate_class) return FALSE; } } return TRUE; }
0
[ "CWE-20" ]
mono
4905ef1130feb26c3150b28b97e4a96752e0d399
80,651,516,441,254,900,000,000,000,000,000,000,000
47
Handle invalid instantiation of generic methods. * verify.c: Add new function to internal verifier API to check method instantiations. * reflection.c (mono_reflection_bind_generic_method_parameters): Check the instantiation before returning it. Fixes #655847
static void io_submit_state_start(struct io_submit_state *state, struct io_ring_ctx *ctx, unsigned int max_ios) { blk_start_plug(&state->plug); #ifdef CONFIG_BLOCK state->plug.nowait = true; #endif state->comp.nr = 0; INIT_LIST_HEAD(&state->comp.list); state->comp.ctx = ctx; state->free_reqs = 0; state->file = NULL; state->ios_left = max_ios; }
0
[ "CWE-416" ]
linux
6d816e088c359866f9867057e04f244c608c42fe
197,309,238,545,837,220,000,000,000,000,000,000,000
14
io_uring: hold 'ctx' reference around task_work queue + execute We're holding the request reference, but we need to go one higher to ensure that the ctx remains valid after the request has finished. If the ring is closed with pending task_work inflight, and the given io_kiocb finishes sync during issue, then we need a reference to the ring itself around the task_work execution cycle. Cc: [email protected] # v5.7+ Reported-by: [email protected] Signed-off-by: Jens Axboe <[email protected]>