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
local struct space *get_space(struct pool *pool) { struct space *space; /* if can't create any more, wait for a space to show up */ possess(pool->have); if (pool->limit == 0) wait_for(pool->have, NOT_TO_BE, 0); /* if a space is available, pull it from the list and return it */ if (pool->head != NULL) { space = pool->head; possess(space->use); pool->head = space->next; twist(pool->have, BY, -1); /* one less in pool */ twist(space->use, TO, 1); /* initially one user */ space->len = 0; return space; } /* nothing available, don't want to wait, make a new space */ assert(pool->limit != 0); if (pool->limit > 0) pool->limit--; pool->made++; release(pool->have); space = MALLOC(sizeof(struct space)); if (space == NULL) bail("not enough memory", ""); space->use = new_lock(1); /* initially one user */ space->buf = MALLOC(pool->size); if (space->buf == NULL) bail("not enough memory", ""); space->size = pool->size; space->len = 0; space->pool = pool; /* remember the pool this belongs to */ return space; }
0
[ "CWE-703", "CWE-22" ]
pigz
fdad1406b3ec809f4954ff7cdf9e99eb18c2458f
275,166,814,343,443,740,000,000,000,000,000,000,000
38
When decompressing with -N or -NT, strip any path from header name. This uses the path of the compressed file combined with the name from the header as the name of the decompressed output file. Any path information in the header name is stripped. This avoids a possible vulnerability where absolute or descending paths are put in the gzip header.
u32 rtl8xxxu_read32(struct rtl8xxxu_priv *priv, u16 addr) { struct usb_device *udev = priv->udev; int len; u32 data; mutex_lock(&priv->usb_buf_mutex); len = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), REALTEK_USB_CMD_REQ, REALTEK_USB_READ, addr, 0, &priv->usb_buf.val32, sizeof(u32), RTW_USB_CONTROL_MSG_TIMEOUT); data = le32_to_cpu(priv->usb_buf.val32); mutex_unlock(&priv->usb_buf_mutex); if (rtl8xxxu_debug & RTL8XXXU_DEBUG_REG_READ) dev_info(&udev->dev, "%s(%04x) = 0x%08x, len %i\n", __func__, addr, data, len); return data; }
0
[ "CWE-400", "CWE-401" ]
linux
a2cdd07488e666aa93a49a3fc9c9b1299e27ef3c
38,185,756,252,611,545,000,000,000,000,000,000,000
19
rtl8xxxu: prevent leaking urb In rtl8xxxu_submit_int_urb if usb_submit_urb fails the allocated urb should be released. Signed-off-by: Navid Emamdoost <[email protected]> Reviewed-by: Chris Chiu <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
rar_read_ahead(struct archive_read *a, size_t min, ssize_t *avail) { struct rar *rar = (struct rar *)(a->format->data); const void *h = __archive_read_ahead(a, min, avail); int ret; if (avail) { if (a->archive.read_data_is_posix_read && *avail > (ssize_t)a->archive.read_data_requested) *avail = a->archive.read_data_requested; if (*avail > rar->bytes_remaining) *avail = (ssize_t)rar->bytes_remaining; if (*avail < 0) return NULL; else if (*avail == 0 && rar->main_flags & MHD_VOLUME && rar->file_flags & FHD_SPLIT_AFTER) { rar->filename_must_match = 1; ret = archive_read_format_rar_read_header(a, a->entry); if (ret == (ARCHIVE_EOF)) { rar->has_endarc_header = 1; ret = archive_read_format_rar_read_header(a, a->entry); } rar->filename_must_match = 0; if (ret != (ARCHIVE_OK)) return NULL; return rar_read_ahead(a, min, avail); } } return h; }
0
[ "CWE-416" ]
libarchive
bfcfe6f04ed20db2504db8a254d1f40a1d84eb28
175,823,950,175,562,770,000,000,000,000,000,000,000
31
rar: file split across multi-part archives must match Fuzzing uncovered some UAF and memory overrun bugs where a file in a single file archive reported that it was split across multiple volumes. This was caused by ppmd7 operations calling rar_br_fillup. This would invoke rar_read_ahead, which would in some situations invoke archive_read_format_rar_read_header. That would check the new file name against the old file name, and if they didn't match up it would free the ppmd7 buffer and allocate a new one. However, because the ppmd7 decoder wasn't actually done with the buffer, it would continue to used the freed buffer. Both reads and writes to the freed region can be observed. This is quite tricky to solve: once the buffer has been freed it is too late, as the ppmd7 decoder functions almost universally assume success - there's no way for ppmd_read to signal error, nor are there good ways for functions like Range_Normalise to propagate them. So we can't detect after the fact that we're in an invalid state - e.g. by checking rar->cursor, we have to prevent ourselves from ever ending up there. So, when we are in the dangerous part or rar_read_ahead that assumes a valid split, we set a flag force read_header to either go down the path for split files or bail. This means that the ppmd7 decoder keeps a valid buffer and just runs out of data. Found with a combination of AFL, afl-rb and qsym.
MYSQL * STDCALL CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, const char *passwd, const char *db, uint port, const char *unix_socket,ulong client_flag) { char buff[NAME_LEN+USERNAME_LENGTH+100]; int scramble_data_len, pkt_scramble_len= 0; char *end,*host_info= 0, *server_version_end, *pkt_end; char *scramble_data; const char *scramble_plugin; ulong pkt_length; NET *net= &mysql->net; #ifdef __WIN__ HANDLE hPipe=INVALID_HANDLE_VALUE; #endif #ifdef HAVE_SYS_UN_H struct sockaddr_un UNIXaddr; #endif DBUG_ENTER("mysql_real_connect"); DBUG_PRINT("enter",("host: %s db: %s user: %s (client)", host ? host : "(Null)", db ? db : "(Null)", user ? user : "(Null)")); /* Test whether we're already connected */ if (net->vio) { set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate); DBUG_RETURN(0); } if (set_connect_attributes(mysql, buff, sizeof(buff))) DBUG_RETURN(0); mysql->methods= &client_methods; net->vio = 0; /* If something goes wrong */ mysql->client_flag=0; /* For handshake */ /* use default options */ if (mysql->options.my_cnf_file || mysql->options.my_cnf_group) { mysql_read_default_options(&mysql->options, (mysql->options.my_cnf_file ? mysql->options.my_cnf_file : "my"), mysql->options.my_cnf_group); my_free(mysql->options.my_cnf_file); my_free(mysql->options.my_cnf_group); mysql->options.my_cnf_file=mysql->options.my_cnf_group=0; } /* Some empty-string-tests are done because of ODBC */ if (!host || !host[0]) host=mysql->options.host; if (!user || !user[0]) { user=mysql->options.user; if (!user) user= ""; } if (!passwd) { passwd=mysql->options.password; #if !defined(DONT_USE_MYSQL_PWD) && !defined(MYSQL_SERVER) if (!passwd) passwd=getenv("MYSQL_PWD"); /* get it from environment */ #endif if (!passwd) passwd= ""; } if (!db || !db[0]) db=mysql->options.db; if (!port) port=mysql->options.port; if (!unix_socket) unix_socket=mysql->options.unix_socket; mysql->server_status=SERVER_STATUS_AUTOCOMMIT; DBUG_PRINT("info", ("Connecting")); /* Part 0: Grab a socket and connect it to the server */ #if defined(HAVE_SMEM) if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) && (!host || !strcmp(host,LOCAL_HOST))) { HANDLE handle_map; DBUG_PRINT("info", ("Using shared memory")); handle_map= create_shared_memory(mysql, net, get_win32_connect_timeout(mysql)); if (handle_map == INVALID_HANDLE_VALUE) { DBUG_PRINT("error", ("host: '%s' socket: '%s' shared memory: %s have_tcpip: %d", host ? host : "<null>", unix_socket ? unix_socket : "<null>", (int) mysql->options.shared_memory_base_name, (int) have_tcpip)); if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) goto error; /* Try also with PIPE or TCP/IP. Clear the error from create_shared_memory(). */ net_clear_error(net); } else { mysql->options.protocol=MYSQL_PROTOCOL_MEMORY; unix_socket = 0; host=mysql->options.shared_memory_base_name; my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_SHARED_MEMORY_CONNECTION), host); } } #endif /* HAVE_SMEM */ #if defined(HAVE_SYS_UN_H) if (!net->vio && (!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_SOCKET) && (unix_socket || mysql_unix_port) && (!host || !strcmp(host,LOCAL_HOST))) { my_socket sock= socket(AF_UNIX, SOCK_STREAM, 0); DBUG_PRINT("info", ("Using socket")); if (sock == SOCKET_ERROR) { set_mysql_extended_error(mysql, CR_SOCKET_CREATE_ERROR, unknown_sqlstate, ER(CR_SOCKET_CREATE_ERROR), socket_errno); goto error; } net->vio= vio_new(sock, VIO_TYPE_SOCKET, VIO_LOCALHOST | VIO_BUFFERED_READ); if (!net->vio) { DBUG_PRINT("error",("Unknow protocol %d ", mysql->options.protocol)); set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate); closesocket(sock); goto error; } host= LOCAL_HOST; if (!unix_socket) unix_socket= mysql_unix_port; host_info= (char*) ER(CR_LOCALHOST_CONNECTION); DBUG_PRINT("info", ("Using UNIX sock '%s'", unix_socket)); memset(&UNIXaddr, 0, sizeof(UNIXaddr)); UNIXaddr.sun_family= AF_UNIX; strmake(UNIXaddr.sun_path, unix_socket, sizeof(UNIXaddr.sun_path)-1); if (vio_socket_connect(net->vio, (struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), get_vio_connect_timeout(mysql))) { DBUG_PRINT("error",("Got error %d on connect to local server", socket_errno)); set_mysql_extended_error(mysql, CR_CONNECTION_ERROR, unknown_sqlstate, ER(CR_CONNECTION_ERROR), unix_socket, socket_errno); vio_delete(net->vio); net->vio= 0; goto error; } mysql->options.protocol=MYSQL_PROTOCOL_SOCKET; } #elif defined(_WIN32) if (!net->vio && (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || (! have_tcpip && (unix_socket || !host && is_NT())))) { hPipe= create_named_pipe(mysql, get_win32_connect_timeout(mysql), &host, &unix_socket); if (hPipe == INVALID_HANDLE_VALUE) { DBUG_PRINT("error", ("host: '%s' socket: '%s' have_tcpip: %d", host ? host : "<null>", unix_socket ? unix_socket : "<null>", (int) have_tcpip)); if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE || (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) || (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE))) goto error; /* Try also with TCP/IP */ } else { net->vio= vio_new_win32pipe(hPipe); my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_NAMEDPIPE_CONNECTION), unix_socket); } } #endif DBUG_PRINT("info", ("net->vio: %p protocol: %d", net->vio, mysql->options.protocol)); if (!net->vio && (!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_TCP)) { struct addrinfo *res_lst, *client_bind_ai_lst= NULL, hints, *t_res; char port_buf[NI_MAXSERV]; my_socket sock= SOCKET_ERROR; int gai_errno, saved_error= 0, status= -1, bind_result= 0; uint flags= VIO_BUFFERED_READ; unix_socket=0; /* This is not used */ if (!port) port= mysql_port; if (!host) host= LOCAL_HOST; my_snprintf(host_info=buff, sizeof(buff)-1, ER(CR_TCP_CONNECTION), host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host, port)); memset(&hints, 0, sizeof(hints)); hints.ai_socktype= SOCK_STREAM; hints.ai_protocol= IPPROTO_TCP; hints.ai_family= AF_UNSPEC; DBUG_PRINT("info",("IPV6 getaddrinfo %s", host)); my_snprintf(port_buf, NI_MAXSERV, "%d", port); gai_errno= getaddrinfo(host, port_buf, &hints, &res_lst); if (gai_errno != 0) { /* For DBUG we are keeping the right message but for client we default to historical error message. */ DBUG_PRINT("info",("IPV6 getaddrinfo error %d", gai_errno)); set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate, ER(CR_UNKNOWN_HOST), host, errno); goto error; } /* Get address info for client bind name if it is provided */ if (mysql->options.ci.bind_address) { int bind_gai_errno= 0; DBUG_PRINT("info",("Resolving addresses for client bind: '%s'", mysql->options.ci.bind_address)); /* Lookup address info for name */ bind_gai_errno= getaddrinfo(mysql->options.ci.bind_address, 0, &hints, &client_bind_ai_lst); if (bind_gai_errno) { DBUG_PRINT("info",("client bind getaddrinfo error %d", bind_gai_errno)); set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate, ER(CR_UNKNOWN_HOST), mysql->options.ci.bind_address, bind_gai_errno); freeaddrinfo(res_lst); goto error; } DBUG_PRINT("info", (" got address info for client bind name")); } /* A hostname might map to multiple IP addresses (IPv4/IPv6). Go over the list of IP addresses until a successful connection can be established. For each IP address, attempt to bind the socket to each client address for the client-side bind hostname until the bind is successful. */ DBUG_PRINT("info", ("Try connect on all addresses for host.")); for (t_res= res_lst; t_res; t_res= t_res->ai_next) { DBUG_PRINT("info", ("Create socket, family: %d type: %d proto: %d", t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol)); sock= socket(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol); if (sock == SOCKET_ERROR) { DBUG_PRINT("info", ("Socket created was invalid")); /* Try next address if there is one */ saved_error= socket_errno; continue; } if (client_bind_ai_lst) { struct addrinfo* curr_bind_ai= NULL; DBUG_PRINT("info", ("Attempting to bind socket to bind address(es)")); /* We'll attempt to bind to each of the addresses returned, until we find one that works. If none works, we'll try the next destination host address (if any) */ curr_bind_ai= client_bind_ai_lst; while (curr_bind_ai != NULL) { /* Attempt to bind the socket to the given address */ bind_result= bind(sock, curr_bind_ai->ai_addr, curr_bind_ai->ai_addrlen); if (!bind_result) break; /* Success */ DBUG_PRINT("info", ("bind failed, attempting another bind address")); /* Problem with the bind, move to next address if present */ curr_bind_ai= curr_bind_ai->ai_next; } if (bind_result) { /* Could not bind to any client-side address with this destination Try the next destination address (if any) */ DBUG_PRINT("info", ("All bind attempts with this address failed")); saved_error= socket_errno; closesocket(sock); continue; } DBUG_PRINT("info", ("Successfully bound client side of socket")); } /* Create a new Vio object to abstract the socket. */ if (!net->vio) { if (!(net->vio= vio_new(sock, VIO_TYPE_TCPIP, flags))) { set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); closesocket(sock); freeaddrinfo(res_lst); if (client_bind_ai_lst) freeaddrinfo(client_bind_ai_lst); goto error; } } /* Just reinitialize if one is already allocated. */ else if (vio_reset(net->vio, VIO_TYPE_TCPIP, sock, NULL, flags)) { set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate); closesocket(sock); freeaddrinfo(res_lst); if (client_bind_ai_lst) freeaddrinfo(client_bind_ai_lst); goto error; } DBUG_PRINT("info", ("Connect socket")); status= vio_socket_connect(net->vio, t_res->ai_addr, t_res->ai_addrlen, get_vio_connect_timeout(mysql)); /* Here we rely on vio_socket_connect() to return success only if the connect attempt was really successful. Otherwise we would stop trying another address, believing we were successful. */ if (!status) break; /* Save either the socket error status or the error code of the failed vio_connection operation. It is necessary to avoid having it overwritten by later operations. */ saved_error= socket_errno; DBUG_PRINT("info", ("No success, close socket, try next address.")); closesocket(sock); } DBUG_PRINT("info", ("End of connect attempts, sock: %d status: %d error: %d", sock, status, saved_error)); freeaddrinfo(res_lst); if (client_bind_ai_lst) freeaddrinfo(client_bind_ai_lst); if (sock == SOCKET_ERROR) { set_mysql_extended_error(mysql, CR_IPSOCK_ERROR, unknown_sqlstate, ER(CR_IPSOCK_ERROR), saved_error); goto error; } if (status) { DBUG_PRINT("error",("Got error %d on connect to '%s'", saved_error, host)); set_mysql_extended_error(mysql, CR_CONN_HOST_ERROR, unknown_sqlstate, ER(CR_CONN_HOST_ERROR), host, saved_error); goto error; } } DBUG_PRINT("info", ("net->vio: %p", net->vio)); if (!net->vio) { DBUG_PRINT("error",("Unknow protocol %d ",mysql->options.protocol)); set_mysql_error(mysql, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate); goto error; } if (my_net_init(net, net->vio)) { vio_delete(net->vio); net->vio = 0; set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); goto error; } vio_keepalive(net->vio,TRUE); /* If user set read_timeout, let it override the default */ if (mysql->options.read_timeout) my_net_set_read_timeout(net, mysql->options.read_timeout); /* If user set write_timeout, let it override the default */ if (mysql->options.write_timeout) my_net_set_write_timeout(net, mysql->options.write_timeout); if (mysql->options.max_allowed_packet) net->max_packet_size= mysql->options.max_allowed_packet; /* Get version info */ mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */ if (mysql->options.connect_timeout && (vio_io_wait(net->vio, VIO_IO_EVENT_READ, get_vio_connect_timeout(mysql)) < 1)) { set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate, ER(CR_SERVER_LOST_EXTENDED), "waiting for initial communication packet", socket_errno); goto error; } /* Part 1: Connection established, read and parse first packet */ DBUG_PRINT("info", ("Read first packet.")); if ((pkt_length=cli_safe_read(mysql)) == packet_error) { if (mysql->net.last_errno == CR_SERVER_LOST) set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate, ER(CR_SERVER_LOST_EXTENDED), "reading initial communication packet", socket_errno); goto error; } pkt_end= (char*)net->read_pos + pkt_length; /* Check if version of protocol matches current one */ mysql->protocol_version= net->read_pos[0]; DBUG_DUMP("packet",(uchar*) net->read_pos,10); DBUG_PRINT("info",("mysql protocol version %d, server=%d", PROTOCOL_VERSION, mysql->protocol_version)); if (mysql->protocol_version != PROTOCOL_VERSION) { set_mysql_extended_error(mysql, CR_VERSION_ERROR, unknown_sqlstate, ER(CR_VERSION_ERROR), mysql->protocol_version, PROTOCOL_VERSION); goto error; } server_version_end= end= strend((char*) net->read_pos+1); mysql->thread_id=uint4korr(end+1); end+=5; /* Scramble is split into two parts because old clients do not understand long scrambles; here goes the first part. */ scramble_data= end; scramble_data_len= SCRAMBLE_LENGTH_323 + 1; scramble_plugin= old_password_plugin_name; end+= scramble_data_len; if (pkt_end >= end + 1) mysql->server_capabilities=uint2korr(end); if (pkt_end >= end + 18) { /* New protocol with 16 bytes to describe server characteristics */ mysql->server_language=end[2]; mysql->server_status=uint2korr(end+3); mysql->server_capabilities|= uint2korr(end+5) << 16; pkt_scramble_len= end[7]; if (pkt_scramble_len < 0) { set_mysql_error(mysql, CR_MALFORMED_PACKET, unknown_sqlstate); /* purecov: inspected */ goto error; } } end+= 18; if (mysql->options.secure_auth && passwd[0] && !(mysql->server_capabilities & CLIENT_SECURE_CONNECTION)) { set_mysql_error(mysql, CR_SECURE_AUTH, unknown_sqlstate); goto error; } if (mysql_init_character_set(mysql)) goto error; /* Save connection information */ if (!my_multi_malloc(MYF(0), &mysql->host_info, (uint) strlen(host_info)+1, &mysql->host, (uint) strlen(host)+1, &mysql->unix_socket,unix_socket ? (uint) strlen(unix_socket)+1 : (uint) 1, &mysql->server_version, (uint) (server_version_end - (char*) net->read_pos + 1), NullS) || !(mysql->user=my_strdup(user,MYF(0))) || !(mysql->passwd=my_strdup(passwd,MYF(0)))) { set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); goto error; } strmov(mysql->host_info,host_info); strmov(mysql->host,host); if (unix_socket) strmov(mysql->unix_socket,unix_socket); else mysql->unix_socket=0; strmov(mysql->server_version,(char*) net->read_pos+1); mysql->port=port; if (pkt_end >= end + SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323 + 1) { /* move the first scramble part - directly in the NET buffer - to get a full continuous scramble. We've read all the header, and can overwrite it now. */ memmove(end - SCRAMBLE_LENGTH_323, scramble_data, SCRAMBLE_LENGTH_323); scramble_data= end - SCRAMBLE_LENGTH_323; if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH) { scramble_data_len= pkt_scramble_len; scramble_plugin= scramble_data + scramble_data_len; if (scramble_data + scramble_data_len > pkt_end) scramble_data_len= pkt_end - scramble_data; } else { scramble_data_len= pkt_end - scramble_data; scramble_plugin= native_password_plugin_name; } } else mysql->server_capabilities&= ~CLIENT_SECURE_CONNECTION; mysql->client_flag= client_flag; /* Part 2: invoke the plugin to send the authentication data to the server */ if (run_plugin_auth(mysql, scramble_data, scramble_data_len, scramble_plugin, db)) goto error; /* Part 3: authenticated, finish the initialization of the connection */ if (mysql->client_flag & CLIENT_COMPRESS) /* We will use compression */ net->compress=1; #ifdef CHECK_LICENSE if (check_license(mysql)) goto error; #endif if (db && !mysql->db && mysql_select_db(mysql, db)) { if (mysql->net.last_errno == CR_SERVER_LOST) set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate, ER(CR_SERVER_LOST_EXTENDED), "Setting intital database", errno); goto error; } /* Using init_commands is not supported when connecting from within the server. */ #ifndef MYSQL_SERVER if (mysql->options.init_commands) { DYNAMIC_ARRAY *init_commands= mysql->options.init_commands; char **ptr= (char**)init_commands->buffer; char **end_command= ptr + init_commands->elements; my_bool reconnect=mysql->reconnect; mysql->reconnect=0; for (; ptr < end_command; ptr++) { int status; if (mysql_real_query(mysql,*ptr, (ulong) strlen(*ptr))) goto error; do { if (mysql->fields) { MYSQL_RES *res; if (!(res= cli_use_result(mysql))) goto error; mysql_free_result(res); } if ((status= mysql_next_result(mysql)) > 0) goto error; } while (status == 0); } mysql->reconnect=reconnect; } #endif DBUG_PRINT("exit", ("Mysql handler: 0x%lx", (long) mysql)); DBUG_RETURN(mysql); error: DBUG_PRINT("error",("message: %u/%s (%s)", net->last_errno, net->sqlstate, net->last_error)); { /* Free alloced memory */ end_server(mysql); mysql_close_free(mysql); if (!(client_flag & CLIENT_REMEMBER_OPTIONS)) mysql_close_free_options(mysql); } DBUG_RETURN(0);
0
[ "CWE-416" ]
mysql-server
4797ea0b772d5f4c5889bc552424132806f46e93
135,640,344,694,269,450,000,000,000,000,000,000,000
649
BUG#17512527: LIST HANDLING INCORRECT IN MYSQL_PRUNE_STMT_LIST() Analysis: --------- Invalid memory access maybe observed when using prepared statements if: a) The mysql client connection is lost after statement preparation is complete and b) There is at least one statement which is in initialized state but not prepared yet. When the client detects a closed connection, it calls end_server() to shutdown the connection. As part of the clean up, the mysql_prune_stmt_list() removes the statements which has transitioned beyond the initialized state and retains only the statements which are in a initialized state. During this processing, the initialized statements are moved from 'mysql->stmts' to a temporary 'pruned_list'. When moving the first 'INIT_DONE' element to the pruned_list, 'element->next' is set to NULL. Hence the rest of the list is never traversed and the statements which have transitioned beyond the initialized state are never invalidated. When the mysql_stmt_close() is called for the statement which is not invalidated; the statements list is updated in order to remove the statement. This would end up accessing freed memory(freed by the mysql_stmt_close() for a previous statement in the list). Fix: --- mysql_prune_stmt_list() called list_add() incorrectly to create a temporary list. The use case of list_add() is to add a single element to the front of the doubly linked list. mysql_prune_stmt_list() called list_add() by passing an entire list as the 'element'. mysql_prune_stmt_list() now uses list_delete() to remove the statement which has transitioned beyond the initialized phase. Thus the statement list would contain only elements where the the state of the statement is initialized. Note: Run the test with valgrind-mysqltest and leak-check=full option to see the invalid memory access.
static void i40e_enable_pf_switch_lb(struct i40e_pf *pf) { struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; struct i40e_vsi_context ctxt; int ret; ctxt.seid = pf->main_vsi_seid; ctxt.pf_num = pf->hw.pf_id; ctxt.vf_num = 0; ret = i40e_aq_get_vsi_params(&pf->hw, &ctxt, NULL); if (ret) { dev_info(&pf->pdev->dev, "couldn't get PF vsi config, err %s aq_err %s\n", i40e_stat_str(&pf->hw, ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); return; } ctxt.flags = I40E_AQ_VSI_TYPE_PF; ctxt.info.valid_sections = cpu_to_le16(I40E_AQ_VSI_PROP_SWITCH_VALID); ctxt.info.switch_id |= cpu_to_le16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB); ret = i40e_aq_update_vsi_params(&vsi->back->hw, &ctxt, NULL); if (ret) { dev_info(&pf->pdev->dev, "update vsi switch failed, err %s aq_err %s\n", i40e_stat_str(&pf->hw, ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); } }
0
[ "CWE-400", "CWE-401" ]
linux
27d461333459d282ffa4a2bdb6b215a59d493a8f
104,367,023,186,887,500,000,000,000,000,000,000,000
29
i40e: prevent memory leak in i40e_setup_macvlans In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory for ch should be released. Signed-off-by: Navid Emamdoost <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
void license_generate_keys(rdpLicense* license) { security_master_secret(license->PremasterSecret, license->ClientRandom, license->ServerRandom, license->MasterSecret); /* MasterSecret */ security_session_key_blob(license->MasterSecret, license->ClientRandom, license->ServerRandom, license->SessionKeyBlob); /* SessionKeyBlob */ security_mac_salt_key(license->SessionKeyBlob, license->ClientRandom, license->ServerRandom, license->MacSaltKey); /* MacSaltKey */ security_licensing_encryption_key(license->SessionKeyBlob, license->ClientRandom, license->ServerRandom, license->LicensingEncryptionKey); /* LicensingEncryptionKey */ #ifdef WITH_DEBUG_LICENSE fprintf(stderr, "ClientRandom:\n"); winpr_HexDump(license->ClientRandom, CLIENT_RANDOM_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "ServerRandom:\n"); winpr_HexDump(license->ServerRandom, SERVER_RANDOM_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "PremasterSecret:\n"); winpr_HexDump(license->PremasterSecret, PREMASTER_SECRET_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "MasterSecret:\n"); winpr_HexDump(license->MasterSecret, MASTER_SECRET_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "SessionKeyBlob:\n"); winpr_HexDump(license->SessionKeyBlob, SESSION_KEY_BLOB_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "MacSaltKey:\n"); winpr_HexDump(license->MacSaltKey, MAC_SALT_KEY_LENGTH); fprintf(stderr, "\n"); fprintf(stderr, "LicensingEncryptionKey:\n"); winpr_HexDump(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH); fprintf(stderr, "\n"); #endif }
0
[]
FreeRDP
f1d6afca6ae620f9855a33280bdc6f3ad9153be0
300,621,595,579,369,300,000,000,000,000,000,000,000
44
Fix CVE-2014-0791 This patch fixes CVE-2014-0791, the remaining length in the stream is checked before doing some malloc().
static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr; struct inet_connection_sock *icsk = inet_csk(sk); struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); struct dccp_sock *dp = dccp_sk(sk); struct in6_addr *saddr = NULL, *final_p, final; struct flowi6 fl6; struct dst_entry *dst; int addr_type; int err; dp->dccps_role = DCCP_ROLE_CLIENT; if (addr_len < SIN6_LEN_RFC2133) return -EINVAL; if (usin->sin6_family != AF_INET6) return -EAFNOSUPPORT; memset(&fl6, 0, sizeof(fl6)); if (np->sndflow) { fl6.flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK; IP6_ECN_flow_init(fl6.flowlabel); if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) { struct ip6_flowlabel *flowlabel; flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); if (flowlabel == NULL) return -EINVAL; fl6_sock_release(flowlabel); } } /* * connect() to INADDR_ANY means loopback (BSD'ism). */ if (ipv6_addr_any(&usin->sin6_addr)) usin->sin6_addr.s6_addr[15] = 1; addr_type = ipv6_addr_type(&usin->sin6_addr); if (addr_type & IPV6_ADDR_MULTICAST) return -ENETUNREACH; if (addr_type & IPV6_ADDR_LINKLOCAL) { if (addr_len >= sizeof(struct sockaddr_in6) && usin->sin6_scope_id) { /* If interface is set while binding, indices * must coincide. */ if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != usin->sin6_scope_id) return -EINVAL; sk->sk_bound_dev_if = usin->sin6_scope_id; } /* Connect to link-local address requires an interface */ if (!sk->sk_bound_dev_if) return -EINVAL; } sk->sk_v6_daddr = usin->sin6_addr; np->flow_label = fl6.flowlabel; /* * DCCP over IPv4 */ if (addr_type == IPV6_ADDR_MAPPED) { u32 exthdrlen = icsk->icsk_ext_hdr_len; struct sockaddr_in sin; SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); if (__ipv6_only_sock(sk)) return -ENETUNREACH; sin.sin_family = AF_INET; sin.sin_port = usin->sin6_port; sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; icsk->icsk_af_ops = &dccp_ipv6_mapped; sk->sk_backlog_rcv = dccp_v4_do_rcv; err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); if (err) { icsk->icsk_ext_hdr_len = exthdrlen; icsk->icsk_af_ops = &dccp_ipv6_af_ops; sk->sk_backlog_rcv = dccp_v6_do_rcv; goto failure; } np->saddr = sk->sk_v6_rcv_saddr; return err; } if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr)) saddr = &sk->sk_v6_rcv_saddr; fl6.flowi6_proto = IPPROTO_DCCP; fl6.daddr = sk->sk_v6_daddr; fl6.saddr = saddr ? *saddr : np->saddr; fl6.flowi6_oif = sk->sk_bound_dev_if; fl6.fl6_dport = usin->sin6_port; fl6.fl6_sport = inet->inet_sport; security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); final_p = fl6_update_dst(&fl6, np->opt, &final); dst = ip6_dst_lookup_flow(sk, &fl6, final_p); if (IS_ERR(dst)) { err = PTR_ERR(dst); goto failure; } if (saddr == NULL) { saddr = &fl6.saddr; sk->sk_v6_rcv_saddr = *saddr; } /* set the source address */ np->saddr = *saddr; inet->inet_rcv_saddr = LOOPBACK4_IPV6; __ip6_dst_store(sk, dst, NULL, NULL); icsk->icsk_ext_hdr_len = 0; if (np->opt != NULL) icsk->icsk_ext_hdr_len = (np->opt->opt_flen + np->opt->opt_nflen); inet->inet_dport = usin->sin6_port; dccp_set_state(sk, DCCP_REQUESTING); err = inet6_hash_connect(&dccp_death_row, sk); if (err) goto late_failure; dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32, sk->sk_v6_daddr.s6_addr32, inet->inet_sport, inet->inet_dport); err = dccp_connect(sk); if (err) goto late_failure; return 0; late_failure: dccp_set_state(sk, DCCP_CLOSED); __sk_dst_reset(sk); failure: inet->inet_dport = 0; sk->sk_route_caps = 0; return err; }
1
[ "CWE-416", "CWE-284", "CWE-264" ]
linux
45f6fad84cc305103b28d73482b344d7f5b76f39
279,166,009,293,414,000,000,000,000,000,000,000,000
157
ipv6: add complete rcu protection around np->opt This patch addresses multiple problems : UDP/RAW sendmsg() need to get a stable struct ipv6_txoptions while socket is not locked : Other threads can change np->opt concurrently. Dmitry posted a syzkaller (http://github.com/google/syzkaller) program desmonstrating use-after-free. Starting with TCP/DCCP lockless listeners, tcp_v6_syn_recv_sock() and dccp_v6_request_recv_sock() also need to use RCU protection to dereference np->opt once (before calling ipv6_dup_options()) This patch adds full RCU protection to np->opt Reported-by: Dmitry Vyukov <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
pthread_mutex_t mutex[32];
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
68,067,445,255,799,550,000,000,000,000,000,000,000
1
Fix other issues in 'CImg<T>::load_bmp()'.
static void cmd_parse_list(struct ImapData *idata, char *s) { struct ImapList *list = NULL; struct ImapList lb; char delimbuf[5]; /* worst case: "\\"\0 */ unsigned int litlen; if (idata->cmddata && idata->cmdtype == IMAP_CT_LIST) list = (struct ImapList *) idata->cmddata; else list = &lb; memset(list, 0, sizeof(struct ImapList)); /* flags */ s = imap_next_word(s); if (*s != '(') { mutt_debug(1, "Bad LIST response\n"); return; } s++; while (*s) { if (mutt_str_strncasecmp(s, "\\NoSelect", 9) == 0) list->noselect = true; else if (mutt_str_strncasecmp(s, "\\NoInferiors", 12) == 0) list->noinferiors = true; /* See draft-gahrns-imap-child-mailbox-?? */ else if (mutt_str_strncasecmp(s, "\\HasNoChildren", 14) == 0) list->noinferiors = true; s = imap_next_word(s); if (*(s - 2) == ')') break; } /* Delimiter */ if (mutt_str_strncasecmp(s, "NIL", 3) != 0) { delimbuf[0] = '\0'; mutt_str_strcat(delimbuf, 5, s); imap_unquote_string(delimbuf); list->delim = delimbuf[0]; } /* Name */ s = imap_next_word(s); /* Notes often responds with literals here. We need a real tokenizer. */ if (imap_get_literal_count(s, &litlen) == 0) { if (imap_cmd_step(idata) != IMAP_CMD_CONTINUE) { idata->status = IMAP_FATAL; return; } list->name = idata->buf; } else { imap_unmunge_mbox_name(idata, s); list->name = s; } if (list->name[0] == '\0') { idata->delim = list->delim; mutt_debug(3, "Root delimiter: %c\n", idata->delim); } }
0
[ "CWE-78", "CWE-77" ]
neomutt
e52393740334443ae0206cab2d7caef381646725
130,246,758,314,127,980,000,000,000,000,000,000,000
70
quote imap strings more carefully Co-authored-by: JerikoOne <[email protected]>
isClick1_clean(XtermWidget xw, XButtonEvent *event) { TScreen *screen = TScreenOf(xw); int delta; /* Disable on Shift-Click-1, including the application-mouse modes */ if (OverrideButton(event) || (okSendMousePos(xw) != MOUSE_OFF) || ExtendingSelection) /* Was moved */ return 0; if (event->type != ButtonRelease) return 0; if (lastButtonDownTime == (Time) 0) { /* first time or once in a blue moon */ delta = screen->multiClickTime + 1; } else if (event->time > lastButtonDownTime) { /* most of the time */ delta = (int) (event->time - lastButtonDownTime); } else { /* time has rolled over since lastButtonUpTime */ delta = (int) ((((Time) ~ 0) - lastButtonDownTime) + event->time); } return delta <= screen->multiClickTime; }
0
[ "CWE-399" ]
xterm-snapshots
82ba55b8f994ab30ff561a347b82ea340ba7075c
184,490,623,068,581,670,000,000,000,000,000,000,000
27
snapshot of project "xterm", label xterm-365d
void doCheckAuthorization(OperationContext* opCtx) const override { uassertStatusOK(_command->checkAuthForOperation( opCtx, _request->getDatabase().toString(), _request->body)); }
0
[ "CWE-20" ]
mongo
722f06f3217c029ef9c50062c8cc775966fd7ead
53,239,322,108,038,320,000,000,000,000,000,000,000
4
SERVER-38275 ban find explain with UUID
R_API char *r_bin_java_unmangle(const char *flags, const char *name, const char *descriptor) { ut32 l_paren_pos = -1, r_paren_pos = -1; char *result = NULL; ut32 desc_len = descriptor && *descriptor ? strlen (descriptor) : 0, name_len = name && *name ? strlen (name) : 0, flags_len = flags && *flags ? strlen (flags) : 0, i = 0; if (desc_len == 0 || name == 0) { return NULL; } for (i = 0; i < desc_len; i++) { if (descriptor[i] == '(') { l_paren_pos = i; } else if (l_paren_pos != (ut32) - 1 && descriptor[i] == ')') { r_paren_pos = i; break; } } // handle field case; if (l_paren_pos == (ut32) - 1 && r_paren_pos == (ut32) - 1) { char *unmangle_field_desc = NULL; ut32 len = extract_type_value (descriptor, &unmangle_field_desc); if (len == 0) { eprintf ("Warning: attempting to unmangle invalid type descriptor.\n"); free (unmangle_field_desc); return result; } if (flags_len > 0) { len += (flags_len + name_len + 5); // space and null result = malloc (len); snprintf (result, len, "%s %s %s", flags, unmangle_field_desc, name); } else { len += (name_len + 5); // space and null result = malloc (len); snprintf (result, len, "%s %s", unmangle_field_desc, name); } free (unmangle_field_desc); } else if (l_paren_pos != (ut32) - 1 && r_paren_pos != (ut32) - 1 && l_paren_pos < r_paren_pos) { // params_len account for l_paren + 1 and null ut32 params_len = r_paren_pos - (l_paren_pos + 1) != 0 ? r_paren_pos - (l_paren_pos + 1) + 1 : 0; char *params = params_len ? malloc (params_len) : NULL; const char *rvalue = descriptor + r_paren_pos + 1; if (params) { snprintf (params, params_len, "%s", descriptor + l_paren_pos + 1); } result = r_bin_java_unmangle_method (flags, name, params, rvalue); free (params); } return result; }
0
[ "CWE-119", "CWE-788" ]
radare2
6c4428f018d385fc80a33ecddcb37becea685dd5
70,695,868,795,174,490,000,000,000,000,000,000,000
52
Improve boundary checks to fix oobread segfaults ##crash * Reported by Cen Zhang via huntr.dev * Reproducer: bins/fuzzed/javaoob-havoc.class
give_terminal_to (pgrp, force) pid_t pgrp; int force; { sigset_t set, oset; int r, e; r = 0; if (job_control || force) { sigemptyset (&set); sigaddset (&set, SIGTTOU); sigaddset (&set, SIGTTIN); sigaddset (&set, SIGTSTP); sigaddset (&set, SIGCHLD); sigemptyset (&oset); sigprocmask (SIG_BLOCK, &set, &oset); if (tcsetpgrp (shell_tty, pgrp) < 0) { /* Maybe we should print an error message? */ #if 0 sys_error ("tcsetpgrp(%d) failed: pid %ld to pgrp %ld", shell_tty, (long)getpid(), (long)pgrp); #endif r = -1; e = errno; } else terminal_pgrp = pgrp; sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); } if (r == -1) errno = e; return r; }
0
[]
bash
955543877583837c85470f7fb8a97b7aa8d45e6c
143,277,150,233,273,760,000,000,000,000,000,000,000
38
bash-4.4-rc2 release
static int do_replace(struct net *net, const void __user *user, unsigned int len) { int ret; struct arpt_replace tmp; struct xt_table_info *newinfo; void *loc_cpu_entry; struct arpt_entry *iter; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; /* overflow check */ if (tmp.num_counters >= INT_MAX / sizeof(struct xt_counters)) return -ENOMEM; if (tmp.num_counters == 0) return -EINVAL; tmp.name[sizeof(tmp.name)-1] = 0; newinfo = xt_alloc_table_info(tmp.size); if (!newinfo) return -ENOMEM; loc_cpu_entry = newinfo->entries; if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; } ret = translate_table(newinfo, loc_cpu_entry, &tmp); if (ret != 0) goto free_newinfo; duprintf("arp_tables: Translated table\n"); ret = __do_replace(net, tmp.name, tmp.valid_hooks, newinfo, tmp.num_counters, tmp.counters); if (ret) goto free_newinfo_untrans; return 0; free_newinfo_untrans: xt_entry_foreach(iter, loc_cpu_entry, newinfo->size) cleanup_entry(iter); free_newinfo: xt_free_table_info(newinfo); return ret; }
0
[ "CWE-119" ]
nf-next
d7591f0c41ce3e67600a982bab6989ef0f07b3ce
204,898,268,157,300,560,000,000,000,000,000,000,000
50
netfilter: x_tables: introduce and use xt_copy_counters_from_user The three variants use same copy&pasted code, condense this into a helper and use that. Make sure info.name is 0-terminated. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
gx_default_get_xfont_device(gx_device * dev) { return dev; }
0
[]
ghostpdl
c9b362ba908ca4b1d7c72663a33229588012d7d9
324,196,041,970,061,260,000,000,000,000,000,000,000
4
Bug 699670: disallow copying of the epo device The erasepage optimisation (epo) subclass device shouldn't be allowed to be copied because the subclass private data, child and parent pointers end up being shared between the original device and the copy. Add an epo_finish_copydevice which NULLs the three offending pointers, and then communicates to the caller that copying is not allowed. This also exposed a separate issue with the stype for subclasses devices. Devices are, I think, unique in having two stype objects associated with them: the usual one in the memory manager header, and the other stored in the device structere directly. In order for the stype to be correct, we have to use the stype for the incoming device, with the ssize of the original device (ssize should reflect the size of the memory allocation). We correctly did so with the stype in the device structure, but then used the prototype device's stype to patch the memory manager stype - meaning the ssize potentially no longer matched the allocated memory. This caused problems in the garbager where there is an implicit assumption that the size of a single object clump (c_alone == 1) is also the size (+ memory manager overheads) of the single object it contains. The solution is to use the same stype instance to patch the memory manager data as we do in the device structure (with the correct ssize).
png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) { /* Libpng versions 1.0.0 and later are binary compatible if the version * string matches through the second '.'; we must recompile any * applications that use any older library version. */ if (user_png_ver != NULL) { int i = -1; int found_dots = 0; do { i++; if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i]) png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; if (user_png_ver[i] == '.') found_dots++; } while (found_dots < 2 && user_png_ver[i] != 0 && PNG_LIBPNG_VER_STRING[i] != 0); } else png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0) { #ifdef PNG_WARNINGS_SUPPORTED size_t pos = 0; char m[128]; pos = png_safecat(m, (sizeof m), pos, "Application built with libpng-"); pos = png_safecat(m, (sizeof m), pos, user_png_ver); pos = png_safecat(m, (sizeof m), pos, " but running with "); pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING); PNG_UNUSED(pos) png_warning(png_ptr, m); #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags = 0; #endif return 0; } /* Success return. */ return 1; }
0
[ "CWE-476" ]
libpng
812768d7a9c973452222d454634496b25ed415eb
258,423,270,353,899,930,000,000,000,000,000,000,000
52
[libpng16] Fixed a potential null pointer dereference in png_set_text_2() (bug report and patch by Patrick Keshishian).
void HGraphBuilder::AddCheckConstantFunction(Handle<JSObject> holder, HValue* receiver, Handle<Map> receiver_map, bool smi_and_map_check) { // Constant functions have the nice property that the map will change if they // are overwritten. Therefore it is enough to check the map of the holder and // its prototypes. if (smi_and_map_check) { AddInstruction(new(zone()) HCheckNonSmi(receiver)); AddInstruction(HCheckMaps::NewWithTransitions(receiver, receiver_map, zone())); } if (!holder.is_null()) { AddInstruction(new(zone()) HCheckPrototypeMaps( Handle<JSObject>(JSObject::cast(receiver_map->prototype())), holder)); } }
0
[]
node
fd80a31e0697d6317ce8c2d289575399f4e06d21
116,882,786,090,192,620,000,000,000,000,000,000,000
17
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
nbd_unlocked_get_meta_context (struct nbd_handle *h, size_t i) { char *ret; if (i >= h->request_meta_contexts.size) { set_error (EINVAL, "meta context request out of range"); return NULL; } ret = strdup (h->request_meta_contexts.ptr[i]); if (ret == NULL) set_error (errno, "strdup"); return ret; }
0
[ "CWE-252" ]
libnbd
c79706af4e7475bf58861a143b77b77a54e7a1cd
279,224,404,321,108,670,000,000,000,000,000,000,000
15
api: Add new API nbd_set_pread_initialize() The recent patch series for CVE-2022-0485 demonstrated that when applications using libnbd are not careful about error checking, the difference on whether a data leak is at least sanitized (all zeroes, partial reads, or data leftover from a prior read) vs. a dangerous information leak (uninitialized data from the heap) was partly under libnbd's control. The previous two patches changed libnbd to always sanitize, as a security hardening technique that prevents heap leaks no matter how buggy the client app is. But a blind memset() also adds an execution delay, even if it doesn't show up as the hot spot in our profiling when compared to the time spent with network traffic. At any rate, if client apps choose to pre-initialize their buffers, or otherwise audit their code to take on their own risk about not dereferencing a buffer on failure paths, then the time spent by libnbd doing memset() is wasted; so it is worth adding a knob to let a user opt in to faster execution at the expense of giving up our memset() hardening on their behalf. In addition to adding two new APIs, this patch also causes changes to the four existing APIs nbd_{aio_,}pread{,_structured}, with those generated lib/api.c changes looking like: | --- lib/api.c.bak 2022-02-10 08:17:09.973381979 -0600 | +++ lib/api.c 2022-02-10 08:22:27.503428024 -0600 | @@ -2871,7 +2914,8 @@ nbd_pread (struct nbd_handle *h, void *b | debug (h, "enter: buf=<buf> count=%zu offset=%" PRIu64 " flags=0x%x", count, offset, flags); | } | | - memset (buf, 0, count); | + if (h->pread_initialize) | + memset (buf, 0, count); | if (unlikely (!pread_in_permitted_state (h))) { | ret = -1; | goto out; Message-Id: <[email protected]> Acked-by: Laszlo Ersek <[email protected]> [eblake: enhance commit message to show generated file diff, mention CVE in doc text] Reviewed-by: Richard W.M. Jones <[email protected]> (cherry picked from commit e0953cb71250947bb97b25e34ff1ea34bd504bf3)
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = -1; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codecpar->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; c->trak_index = -1; // Here stsc refers to a chunk not described in stco. This is technically invalid, // but we can overlook it (clearing stsc) whenever stts_count == 0 (indicating no samples). if (!sc->chunk_count && !sc->stts_count && sc->stsc_count) { sc->stsc_count = 0; av_freep(&sc->stsc_data); } /* sanity checks */ if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) || (!sc->chunk_count && sc->sample_count)) { av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) { av_log(c->fc, AV_LOG_ERROR, "stream %d, contradictionary STSC and STCO\n", st->index); return AVERROR_INVALIDDATA; } fix_timescale(c, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (c->enable_drefs) { if (mov_open_dref(c, &sc->pb, c->fc->url, dref) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { av_log(c->fc, AV_LOG_WARNING, "Skipped opening external track: " "stream %d, alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d." "Set enable_drefs to allow this.\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } } else { sc->pb = c->fc->pb; sc->pb_is_copied = 1; } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codecpar->width && st->codecpar->height && sc->height && sc->width && (st->codecpar->width != sc->width || st->codecpar->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codecpar->height * sc->width) / ((double)st->codecpar->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } // done for ai5q, ai52, ai55, ai1q, ai12 and ai15. if (!st->codecpar->extradata_size && st->codecpar->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codecpar->codec_tag)) { ret = ff_generate_avci_extradata(st); if (ret < 0) return ret; } switch (st->codecpar->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codecpar->width = 0; /* let decoder init width/height */ st->codecpar->height= 0; break; } // If the duration of the mp3 packets is not constant, then they could need a parser if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codecpar->sample_rate) { ffstream(st)->need_parsing = AVSTREAM_PARSE_FULL; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); av_freep(&sc->sync_group); av_freep(&sc->sgpd_sync); return 0; }
0
[ "CWE-703" ]
FFmpeg
c953baa084607dd1d84c3bfcce3cf6a87c3e6e05
150,259,372,779,413,260,000,000,000,000,000,000,000
130
avformat/mov: Check count sums in build_open_gop_key_points() Fixes: ffmpeg.md Fixes: Out of array access Fixes: CVE-2022-2566 Found-by: Andy Nguyen <[email protected]> Found-by: 3pvd <[email protected]> Reviewed-by: Andy Nguyen <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
bjc_put_continue_image(gp_file *file, const byte *data, int count) { bjc_put_command(file, 'F', count); bjc_put_bytes(file, data, count); }
0
[ "CWE-787" ]
ghostpdl
bf72f1a3dd5392ee8291e3b1518a0c2c5dc6ba39
264,312,421,214,414,460,000,000,000,000,000,000,000
5
Fix valgrind problems with gdevbjca.c 2 problems here. Firstly, we could access off the end of a row while looking for runs. Change the indexing to fix this. Secondly, we could overrun our gamma tables due to unexpectedly large values. Add some clamping.
std::string get_saves_dir() { const std::string dir_path = get_user_data_dir() + "/saves"; return get_dir(dir_path); }
0
[ "CWE-200" ]
wesnoth
af61f9fdd15cd439da9e2fe5fa39d174c923eaae
295,328,135,580,627,000,000,000,000,000,000,000,000
5
fs: Use game data path to resolve ./ in the absence of a current_dir Fixes a file content disclosure bug (#22042) affecting functionality relying on the get_wml_location() function and not passing a non-empty value for the current_dir parameter. See <https://gna.org/bugs/?22042> for details. This is a candidate for the 1.10 and 1.12 branches. (Backported from master, commit 314425ab0e57b32909d324f7d4bf213d62cbd3b5.)
static void copy_xauthority(void) { // copy XAUTHORITY_FILE in the new home directory char *src = RUN_XAUTHORITY_FILE ; char *dest; if (asprintf(&dest, "%s/.Xauthority", cfg.homedir) == -1) errExit("asprintf"); // if destination is a symbolic link, exit the sandbox!!! if (is_link(dest)) { fprintf(stderr, "Error: %s is a symbolic link\n", dest); exit(1); } copy_file_as_user(src, dest, getuid(), getgid(), S_IRUSR | S_IWUSR); fs_logger2("clone", dest); // delete the temporary file unlink(src); }
0
[ "CWE-284", "CWE-269" ]
firejail
38d418505e9ee2d326557e5639e8da49c298858f
274,363,467,470,374,650,000,000,000,000,000,000,000
19
security fix
void parser(void) { char *arg; #ifndef MINIMAL char *sitearg; #endif #ifdef WITH_RFC2640 char *narg = NULL; #endif size_t n; #ifdef IMPLICIT_TLS (void) tls_init_new_session(); data_protection_level = CPL_PRIVATE; #endif for (;;) { xferfd = -1; if (state_needs_update != 0) { state_needs_update = 0; setprocessname("pure-ftpd (IDLE)"); #ifdef FTPWHO if (shm_data_cur != NULL) { ftpwho_lock(); shm_data_cur->state = FTPWHO_STATE_IDLE; *shm_data_cur->filename = 0; ftpwho_unlock(); } #endif } doreply(); alarm(idletime * 2); switch (sfgets()) { case -1: #ifdef BORING_MODE die(421, LOG_INFO, MSG_TIMEOUT); #else die(421, LOG_INFO, MSG_TIMEOUT_PARSER); #endif case -2: return; } #ifdef DEBUG if (debug != 0) { addreply(0, "%s", cmd); } #endif n = (size_t) 0U; while ((isalpha((unsigned char) cmd[n]) || cmd[n] == '@') && n < cmdsize) { cmd[n] = (char) tolower((unsigned char) cmd[n]); n++; } if (n >= cmdsize) { /* overparanoid, it should never happen */ die(421, LOG_WARNING, MSG_LINE_TOO_LONG); } if (n == (size_t) 0U) { nop: addreply_noformat(500, "?"); continue; } #ifdef SKIP_COMMAND_TRAILING_SPACES while (isspace((unsigned char) cmd[n]) && n < cmdsize) { cmd[n++] = 0; } arg = cmd + n; while (cmd[n] != 0 && n < cmdsize) { n++; } n--; while (isspace((unsigned char) cmd[n])) { cmd[n--] = 0; } #else if (cmd[n] == 0) { arg = cmd + n; } else if (isspace((unsigned char) cmd[n])) { cmd[n] = 0; arg = cmd + n + 1; } else { goto nop; } #endif if (logging != 0) { #ifdef DEBUG logfile(LOG_DEBUG, MSG_DEBUG_COMMAND " [%s] [%s]", cmd, arg); #else logfile(LOG_DEBUG, MSG_DEBUG_COMMAND " [%s] [%s]", cmd, strcmp(cmd, "pass") ? arg : "<*>"); #endif } #ifdef WITH_RFC2640 narg = charset_client2fs(arg); arg = narg; #endif /* * antiidle() is called with dummy commands, usually used by clients * who are wanting extra idle time. We give them some, but not too much. * When we jump to wayout, the idle timer is not zeroed. It means that * we didn't issue an 'active' command like RETR. */ #ifndef MINIMAL if (!strcmp(cmd, "noop")) { antiidle(); donoop(); goto wayout; } #endif if (!strcmp(cmd, "user")) { #ifdef WITH_TLS if (enforce_tls_auth > 1 && tls_cnx == NULL) { die(421, LOG_WARNING, MSG_TLS_NEEDED); } #endif douser(arg); } else if (!strcmp(cmd, "acct")) { addreply(202, MSG_WHOAREYOU); } else if (!strcmp(cmd, "pass")) { if (guest == 0) { randomdelay(); } dopass(arg); } else if (!strcmp(cmd, "quit")) { addreply(221, MSG_GOODBYE, (unsigned long long) ((uploaded + 1023ULL) / 1024ULL), (unsigned long long) ((downloaded + 1023ULL) / 1024ULL)); return; } else if (!strcmp(cmd, "syst")) { antiidle(); addreply_noformat(215, "UNIX Type: L8"); goto wayout; #ifdef WITH_TLS } else if (enforce_tls_auth > 0 && !strcmp(cmd, "auth") && !strcasecmp(arg, "tls")) { addreply_noformat(234, "AUTH TLS OK."); doreply(); if (tls_cnx == NULL) { flush_cmd(); (void) tls_init_new_session(); } goto wayout; } else if (!strcmp(cmd, "pbsz")) { addreply_noformat(tls_cnx == NULL ? 503 : 200, "PBSZ=0"); } else if (!strcmp(cmd, "prot")) { if (tls_cnx == NULL) { addreply_noformat(503, MSG_PROT_BEFORE_PBSZ); goto wayout; } switch (*arg) { case 0: addreply_noformat(503, MSG_MISSING_ARG); data_protection_level = CPL_NONE; break; case 'C': if (arg[1] == 0) { addreply(200, MSG_PROT_OK, "clear"); data_protection_level = CPL_CLEAR; break; } case 'S': case 'E': if (arg[1] == 0) { addreply(200, MSG_PROT_UNKNOWN_LEVEL, arg, "private"); data_protection_level = CPL_PRIVATE; break; } case 'P': if (arg[1] == 0) { addreply(200, MSG_PROT_OK, "private"); data_protection_level = CPL_PRIVATE; break; } default: addreply_noformat(534, "Fallback to [C]"); data_protection_level = CPL_CLEAR; break; } #endif } else if (!strcmp(cmd, "auth") || !strcmp(cmd, "adat")) { addreply_noformat(500, MSG_AUTH_UNIMPLEMENTED); } else if (!strcmp(cmd, "type")) { antiidle(); dotype(arg); goto wayout; } else if (!strcmp(cmd, "mode")) { antiidle(); domode(arg); goto wayout; #ifndef MINIMAL } else if (!strcmp(cmd, "feat")) { dofeat(); goto wayout; } else if (!strcmp(cmd, "opts")) { doopts(arg); goto wayout; #endif } else if (!strcmp(cmd, "stru")) { dostru(arg); goto wayout; #ifndef MINIMAL } else if (!strcmp(cmd, "help")) { goto help_site; #endif #ifdef DEBUG } else if (!strcmp(cmd, "xdbg")) { debug++; addreply(200, MSG_XDBG_OK, debug); goto wayout; #endif } else if (loggedin == 0) { /* from this point, all commands need authentication */ addreply_noformat(530, MSG_NOT_LOGGED_IN); goto wayout; } else { if (!strcmp(cmd, "cwd") || !strcmp(cmd, "xcwd")) { antiidle(); docwd(arg); goto wayout; } else if (!strcmp(cmd, "port")) { doport(arg); #ifndef MINIMAL } else if (!strcmp(cmd, "eprt")) { doeprt(arg); } else if (!strcmp(cmd, "esta") && disallow_passive == 0 && STORAGE_FAMILY(force_passive_ip) == 0) { doesta(); } else if (!strcmp(cmd, "estp")) { doestp(); #endif } else if (disallow_passive == 0 && (!strcmp(cmd, "pasv") || !strcmp(cmd, "p@sw"))) { dopasv(0); } else if (disallow_passive == 0 && (!strcmp(cmd, "epsv") && (broken_client_compat == 0 || STORAGE_FAMILY(ctrlconn) == AF_INET6))) { if (!strcasecmp(arg, "all")) { epsv_all = 1; addreply_noformat(220, MSG_ACTIVE_DISABLED); } else if (!strcmp(arg, "2") && !v6ready) { addreply_noformat(522, MSG_ONLY_IPV4); } else { dopasv(1); } #ifndef MINIMAL } else if (disallow_passive == 0 && !strcmp(cmd, "spsv")) { dopasv(2); } else if (!strcmp(cmd, "allo")) { if (*arg == 0) { addreply_noformat(501, MSG_STAT_FAILURE); } else { const off_t size = (off_t) strtoull(arg, NULL, 10); if (size < (off_t) 0) { addreply_noformat(501, MSG_STAT_FAILURE); } else { doallo(size); } } #endif } else if (!strcmp(cmd, "pwd") || !strcmp(cmd, "xpwd")) { #ifdef WITH_RFC2640 char *nwd; #endif antiidle(); #ifdef WITH_RFC2640 nwd = charset_fs2client(wd); addreply(257, "\"%s\" " MSG_IS_YOUR_CURRENT_LOCATION, nwd); free(nwd); #else addreply(257, "\"%s\" " MSG_IS_YOUR_CURRENT_LOCATION, wd); #endif goto wayout; } else if (!strcmp(cmd, "cdup") || !strcmp(cmd, "xcup")) { docwd(".."); } else if (!strcmp(cmd, "retr")) { if (*arg != 0) { #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { doretr(arg); } } else { addreply_noformat(501, MSG_NO_FILE_NAME); } } else if (!strcmp(cmd, "rest")) { antiidle(); if (*arg != 0) { dorest(arg); } else { addreply_noformat(501, MSG_NO_RESTART_POINT); restartat = (off_t) 0; } goto wayout; } else if (!strcmp(cmd, "dele")) { if (*arg != 0) { dodele(arg); } else { addreply_noformat(501, MSG_NO_FILE_NAME); } } else if (!strcmp(cmd, "stor")) { arg = revealextraspc(arg); if (*arg != 0) { #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { dostor(arg, 0, autorename); } } else { addreply_noformat(501, MSG_NO_FILE_NAME); } } else if (!strcmp(cmd, "appe")) { arg = revealextraspc(arg); if (*arg != 0) { #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { dostor(arg, 1, 0); } } else { addreply_noformat(501, MSG_NO_FILE_NAME); } #ifndef MINIMAL } else if (!strcmp(cmd, "stou")) { #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { dostou(); } #endif #ifndef DISABLE_MKD_RMD } else if (!strcmp(cmd, "mkd") || !strcmp(cmd, "xmkd")) { arg = revealextraspc(arg); if (*arg != 0) { domkd(arg); } else { addreply_noformat(501, MSG_NO_DIRECTORY_NAME); } } else if (!strcmp(cmd, "rmd") || !strcmp(cmd, "xrmd")) { if (*arg != 0) { dormd(arg); } else { addreply_noformat(550, MSG_NO_DIRECTORY_NAME); } #endif #ifndef MINIMAL } else if (!strcmp(cmd, "stat")) { if (*arg != 0) { modern_listings = 0; donlist(arg, 1, 1, 1, 1); } else { addreply_noformat(211, "http://www.pureftpd.org/"); } #endif } else if (!strcmp(cmd, "list")) { #ifndef MINIMAL modern_listings = 0; #endif #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { donlist(arg, 0, 1, 0, 1); } } else if (!strcmp(cmd, "nlst")) { #ifndef MINIMAL modern_listings = 0; #endif #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { donlist(arg, 0, 0, 0, broken_client_compat); } #ifndef MINIMAL } else if (!strcmp(cmd, "mlst")) { #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { domlst(*arg != 0 ? arg : "."); } } else if (!strcmp(cmd, "mlsd")) { modern_listings = 1; #ifdef WITH_TLS if (enforce_tls_auth == 3 && data_protection_level != CPL_PRIVATE) { addreply_noformat(521, MSG_PROT_PRIVATE_NEEDED); } else #endif { donlist(arg, 0, 1, 1, 0); } #endif } else if (!strcmp(cmd, "abor")) { addreply_noformat(226, MSG_ABOR_SUCCESS); #ifndef MINIMAL } else if (!strcmp(cmd, "site")) { if ((sitearg = arg) != NULL) { while (*sitearg != 0 && !isspace((unsigned char) *sitearg)) { sitearg++; } if (*sitearg != 0) { *sitearg++ = 0; } } if (!strcasecmp(arg, "idle")) { if (sitearg == NULL || *sitearg == 0) { addreply_noformat(501, "SITE IDLE: " MSG_MISSING_ARG); } else { unsigned long int i = 0; i = strtoul(sitearg, &sitearg, 10); if (sitearg && *sitearg) addreply(501, MSG_GARBAGE_FOUND " : %s", sitearg); else if (i > MAX_SITE_IDLE) addreply_noformat(501, MSG_VALUE_TOO_LARGE); else { idletime = i; addreply(200, MSG_IDLE_TIME, idletime); idletime_noop = (double) idletime * 2.0; } } } else if (!strcasecmp(arg, "time")) { dositetime(); } else if (!strcasecmp(arg, "help")) { help_site: addreply_noformat(214, MSG_SITE_HELP CRLF # ifdef WITH_DIRALIASES " ALIAS" CRLF # endif " CHMOD" CRLF " IDLE" CRLF " UTIME"); addreply_noformat(214, "Pure-FTPd - http://pureftpd.org/"); } else if (!strcasecmp(arg, "chmod")) { char *sitearg2; mode_t mode; parsechmod: if (sitearg == NULL || *sitearg == 0) { addreply_noformat(501, MSG_MISSING_ARG); goto chmod_wayout; } sitearg2 = sitearg; while (*sitearg2 != 0 && !isspace((unsigned char) *sitearg2)) { sitearg2++; } while (*sitearg2 != 0 && isspace((unsigned char) *sitearg2)) { sitearg2++; } if (*sitearg2 == 0) { addreply_noformat(550, MSG_NO_FILE_NAME); goto chmod_wayout; } mode = (mode_t) strtoul(sitearg, NULL, 8); if (mode > (mode_t) 07777) { addreply_noformat(501, MSG_BAD_CHMOD); goto chmod_wayout; } dochmod(sitearg2, mode); chmod_wayout: (void) 0; } else if (!strcasecmp(arg, "utime")) { char *sitearg2; if (sitearg == NULL || *sitearg == 0) { addreply_noformat(501, MSG_NO_FILE_NAME); goto utime_wayout; } if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || sitearg2 == sitearg) { addreply_noformat(501, MSG_MISSING_ARG); goto utime_wayout; } if (strcasecmp(sitearg2, " UTC") != 0) { addreply_noformat(500, "UTC Only"); goto utime_wayout; } *sitearg2-- = 0; if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || sitearg2 == sitearg) { utime_no_arg: addreply_noformat(501, MSG_MISSING_ARG); goto utime_wayout; } *sitearg2-- = 0; if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || sitearg2 == sitearg) { goto utime_no_arg; } *sitearg2-- = 0; if ((sitearg2 = strrchr(sitearg, ' ')) == NULL || sitearg2 == sitearg) { goto utime_no_arg; } *sitearg2++ = 0; if (*sitearg2 == 0) { goto utime_no_arg; } doutime(sitearg, sitearg2); utime_wayout: (void) 0; # ifdef WITH_DIRALIASES } else if (!strcasecmp(arg, "alias")) { if (sitearg == NULL || *sitearg == 0) { print_aliases(); } else { const char *alias; if ((alias = lookup_alias(sitearg)) != NULL) { addreply(214, MSG_ALIASES_ALIAS, sitearg, alias); } else { addreply(502, MSG_ALIASES_UNKNOWN, sitearg); } } # endif } else if (*arg != 0) { addreply(500, "SITE %s " MSG_UNKNOWN_EXTENSION, arg); } else { addreply_noformat(500, "SITE: " MSG_MISSING_ARG); } #endif } else if (!strcmp(cmd, "mdtm")) { domdtm(arg); } else if (!strcmp(cmd, "size")) { dosize(arg); #ifndef MINIMAL } else if (!strcmp(cmd, "chmod")) { sitearg = arg; goto parsechmod; #endif } else if (!strcmp(cmd, "rnfr")) { if (*arg != 0) { dornfr(arg); } else { addreply_noformat(550, MSG_NO_FILE_NAME); } } else if (!strcmp(cmd, "rnto")) { arg = revealextraspc(arg); if (*arg != 0) { dornto(arg); } else { addreply_noformat(550, MSG_NO_FILE_NAME); } } else { addreply_noformat(500, MSG_UNKNOWN_COMMAND); } } noopidle = (time_t) -1; wayout: #ifdef WITH_RFC2640 free(narg); narg = NULL; #endif #ifdef THROTTLING if (throttling_delay != 0UL) { usleep2(throttling_delay); } #else (void) 0; #endif } }
0
[ "CWE-399" ]
pure-ftpd
65c4d4ad331e94661de763e9b5304d28698999c4
187,874,985,686,837,440,000,000,000,000,000,000,000
591
Flush the command buffer after switching to TLS. Fixes a flaw similar to CVE-2011-0411.
static void lhvc_parse_rep_format(HEVC_RepFormat *fmt, GF_BitStream *bs, u32 idx) { u8 chroma_bitdepth_present_flag; fmt->pic_width_luma_samples = gf_bs_read_int_log_idx(bs, 16, "pic_width_luma_samples", idx); fmt->pic_height_luma_samples = gf_bs_read_int_log_idx(bs, 16, "pic_height_luma_samples", idx); chroma_bitdepth_present_flag = gf_bs_read_int_log_idx(bs, 1, "chroma_bitdepth_present_flag", idx); if (chroma_bitdepth_present_flag) { fmt->chroma_format_idc = gf_bs_read_int_log_idx(bs, 2, "chroma_format_idc", idx); if (fmt->chroma_format_idc == 3) fmt->separate_colour_plane_flag = gf_bs_read_int_log_idx(bs, 1, "separate_colour_plane_flag", idx); fmt->bit_depth_luma = 8 + gf_bs_read_int_log_idx(bs, 4, "bit_depth_luma_minus8", idx); fmt->bit_depth_chroma = 8 + gf_bs_read_int_log_idx(bs, 4, "bit_depth_chroma_minus8", idx); } if (gf_bs_read_int_log_idx(bs, 1, "conformance_window_vps_flag", idx)) { gf_bs_read_ue_log_idx(bs, "conf_win_vps_left_offset", idx); gf_bs_read_ue_log_idx(bs, "conf_win_vps_right_offset", idx); gf_bs_read_ue_log_idx(bs, "conf_win_vps_top_offset", idx); gf_bs_read_ue_log_idx(bs, "conf_win_vps_bottom_offset", idx); } }
0
[ "CWE-190", "CWE-787" ]
gpac
51cdb67ff7c5f1242ac58c5aa603ceaf1793b788
198,692,843,804,381,350,000,000,000,000,000,000,000
21
add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722
init_cell_pool(void) { tor_assert(!cell_pool); cell_pool = mp_pool_new(sizeof(packed_cell_t), 128*1024); }
0
[ "CWE-200", "CWE-617" ]
tor
56a7c5bc15e0447203a491c1ee37de9939ad1dcd
285,571,214,331,179,900,000,000,000,000,000,000,000
5
TROVE-2017-005: Fix assertion failure in connection_edge_process_relay_cell On an hidden service rendezvous circuit, a BEGIN_DIR could be sent (maliciously) which would trigger a tor_assert() because connection_edge_process_relay_cell() thought that the circuit is an or_circuit_t but is an origin circuit in reality. Fixes #22494 Reported-by: Roger Dingledine <[email protected]> Signed-off-by: David Goulet <[email protected]>
static int dt_to_map_one_config(struct pinctrl *p, struct pinctrl_dev *hog_pctldev, const char *statename, struct device_node *np_config) { struct pinctrl_dev *pctldev = NULL; struct device_node *np_pctldev; const struct pinctrl_ops *ops; int ret; struct pinctrl_map *map; unsigned num_maps; bool allow_default = false; /* Find the pin controller containing np_config */ np_pctldev = of_node_get(np_config); for (;;) { if (!allow_default) allow_default = of_property_read_bool(np_pctldev, "pinctrl-use-default"); np_pctldev = of_get_next_parent(np_pctldev); if (!np_pctldev || of_node_is_root(np_pctldev)) { of_node_put(np_pctldev); /* keep deferring if modules are enabled unless we've timed out */ if (IS_ENABLED(CONFIG_MODULES) && !allow_default) return driver_deferred_probe_check_state_continue(p->dev); return driver_deferred_probe_check_state(p->dev); } /* If we're creating a hog we can use the passed pctldev */ if (hog_pctldev && (np_pctldev == p->dev->of_node)) { pctldev = hog_pctldev; break; } pctldev = get_pinctrl_dev_from_of_node(np_pctldev); if (pctldev) break; /* Do not defer probing of hogs (circular loop) */ if (np_pctldev == p->dev->of_node) { of_node_put(np_pctldev); return -ENODEV; } } of_node_put(np_pctldev); /* * Call pinctrl driver to parse device tree node, and * generate mapping table entries */ ops = pctldev->desc->pctlops; if (!ops->dt_node_to_map) { dev_err(p->dev, "pctldev %s doesn't support DT\n", dev_name(pctldev->dev)); return -ENODEV; } ret = ops->dt_node_to_map(pctldev, np_config, &map, &num_maps); if (ret < 0) return ret; /* Stash the mapping table chunk away for later use */ return dt_remember_or_free_map(p, statename, pctldev, map, num_maps); }
0
[ "CWE-125" ]
linux
be4c60b563edee3712d392aaeb0943a768df7023
62,357,666,261,852,450,000,000,000,000,000,000,000
62
pinctrl: devicetree: Avoid taking direct reference to device name string When populating the pinctrl mapping table entries for a device, the 'dev_name' field for each entry is initialised to point directly at the string returned by 'dev_name()' for the device and subsequently used by 'create_pinctrl()' when looking up the mappings for the device being probed. This is unreliable in the presence of calls to 'dev_set_name()', which may reallocate the device name string leaving the pinctrl mappings with a dangling reference. This then leads to a use-after-free every time the name is dereferenced by a device probe: | BUG: KASAN: invalid-access in strcmp+0x20/0x64 | Read of size 1 at addr 13ffffc153494b00 by task modprobe/590 | Pointer tag: [13], memory tag: [fe] | | Call trace: | __kasan_report+0x16c/0x1dc | kasan_report+0x10/0x18 | check_memory_region | __hwasan_load1_noabort+0x4c/0x54 | strcmp+0x20/0x64 | create_pinctrl+0x18c/0x7f4 | pinctrl_get+0x90/0x114 | devm_pinctrl_get+0x44/0x98 | pinctrl_bind_pins+0x5c/0x450 | really_probe+0x1c8/0x9a4 | driver_probe_device+0x120/0x1d8 Follow the example of sysfs, and duplicate the device name string before stashing it away in the pinctrl mapping entries. Cc: Linus Walleij <[email protected]> Reported-by: Elena Petrova <[email protected]> Tested-by: Elena Petrova <[email protected]> Signed-off-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
void do_remove_file(struct st_command *command) { int error; static DYNAMIC_STRING ds_filename; const struct command_arg rm_args[] = { { "filename", ARG_STRING, TRUE, &ds_filename, "File to delete" } }; DBUG_ENTER("do_remove_file"); check_command_args(command, command->first_argument, rm_args, sizeof(rm_args)/sizeof(struct command_arg), ' '); DBUG_PRINT("info", ("removing file: %s", ds_filename.str)); error= my_delete(ds_filename.str, MYF(disable_warnings ? 0 : MY_WME)) != 0; handle_command_error(command, error, my_errno); dynstr_free(&ds_filename); DBUG_VOID_RETURN; }
0
[]
server
01b39b7b0730102b88d8ea43ec719a75e9316a1e
336,296,002,941,940,520,000,000,000,000,000,000,000
19
mysqltest: don't eat new lines in --exec pass them through as is
void LOG_SetMinSeverity(LOG_Severity severity) { log_min_severity = CLAMP(LOGS_DEBUG, severity, LOGS_FATAL); }
0
[ "CWE-59" ]
chrony
e18903a6b56341481a2e08469c0602010bf7bfe3
146,354,383,914,686,420,000,000,000,000,000,000,000
4
switch to new util file functions Replace all fopen(), rename(), and unlink() calls with the new util functions.
roundLog2 (int x, LevelRoundingMode rmode) { return (rmode == ROUND_DOWN)? floorLog2 (x): ceilLog2 (x); }
0
[ "CWE-125" ]
openexr
e79d2296496a50826a15c667bf92bdc5a05518b4
244,647,114,161,895,740,000,000,000,000,000,000,000
4
fix memory leaks and invalid memory accesses Signed-off-by: Peter Hillman <[email protected]>
static int mounts_release(struct inode *inode, struct file *file) { struct proc_mounts *p = file->private_data; path_put(&p->root); put_mnt_ns(p->ns); return seq_release(inode, file); }
0
[ "CWE-20", "CWE-362", "CWE-416" ]
linux
86acdca1b63e6890540fa19495cfc708beff3d8b
323,042,036,360,905,900,000,000,000,000,000,000,000
7
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]>
void acceptXdsConnection() { AssertionResult result = // xds_connection_ is filled with the new FakeHttpConnection. fake_upstreams_[0]->waitForHttpConnection(*dispatcher_, xds_connection_); RELEASE_ASSERT(result, result.message()); result = xds_connection_->waitForNewStream(*dispatcher_, xds_stream_); RELEASE_ASSERT(result, result.message()); xds_stream_->startGrpcStream(); verifyGrpcServiceMethod(); }
0
[ "CWE-703", "CWE-674" ]
envoy
4b6dd3b53cd5c6d4d4df378a2fc62c1707522b31
301,412,356,780,288,500,000,000,000,000,000,000,000
9
CVE-2022-23606 Avoid closing other connections to prevent deep recursion when a large number of idle connections are closed at the start of a pool drain, when a connection is closed. Signed-off-by: Yan Avlasov <[email protected]>
void check_user_namespace(void) { EUID_ASSERT(); if (getuid() == 0) goto errout; // test user namespaces available in the kernel struct stat s1; struct stat s2; struct stat s3; if (stat("/proc/self/ns/user", &s1) == 0 && stat("/proc/self/uid_map", &s2) == 0 && stat("/proc/self/gid_map", &s3) == 0) arg_noroot = 1; else goto errout; return; errout: fwarning("noroot option is not available\n"); arg_noroot = 0; }
0
[ "CWE-269", "CWE-94" ]
firejail
27cde3d7d1e4e16d4190932347c7151dc2a84c50
75,492,344,756,163,270,000,000,000,000,000,000,000
23
fixing CVE-2022-31214
void HeaderMapImpl::addCopy(const LowerCaseString& key, const std::string& value) { auto* entry = getExistingInline(key.get()); if (entry != nullptr) { const uint64_t added_size = appendToHeader(entry->value(), value); addSize(added_size); return; } HeaderString new_key; new_key.setCopy(key.get().c_str(), key.get().size()); HeaderString new_value; new_value.setCopy(value.c_str(), value.size()); insertByKey(std::move(new_key), std::move(new_value)); ASSERT(new_key.empty()); // NOLINT(bugprone-use-after-move) ASSERT(new_value.empty()); // NOLINT(bugprone-use-after-move) }
0
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
63,008,782,411,544,175,000,000,000,000,000,000,000
15
Track byteSize of HeaderMap internally. Introduces a cached byte size updated internally in HeaderMap. The value is stored as an optional, and is cleared whenever a non-const pointer or reference to a HeaderEntry is accessed. The cached value can be set with refreshByteSize() which performs an iteration over the HeaderMap to sum the size of each key and value in the HeaderMap. Signed-off-by: Asra Ali <[email protected]>
GF_Err st3d_box_read(GF_Box *s, GF_BitStream *bs) { GF_Stereo3DBox *ptr = (GF_Stereo3DBox *)s; ISOM_DECREASE_SIZE(ptr, 1) ptr->stereo_type = gf_bs_read_u8(bs); return GF_OK;
0
[ "CWE-476", "CWE-787" ]
gpac
b8f8b202d4fc23eb0ab4ce71ae96536ca6f5d3f8
229,787,868,620,413,900,000,000,000,000,000,000,000
7
fixed #1757
static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, const size_t pad) { double extent; size_t quantum; /* Check if there is enough storage for drawing pimitives. */ extent=(double) mvg_info->offset+pad+PrimitiveExtentPad; quantum=sizeof(**mvg_info->primitive_info); if (((extent*quantum) < (double) SSIZE_MAX) && ((extent*quantum) < (double) GetMaxMemoryRequest())) { if (extent <= (double) *mvg_info->extent) return(MagickTrue); *mvg_info->primitive_info=(PrimitiveInfo *) ResizeQuantumMemory( *mvg_info->primitive_info,(size_t) extent,quantum); if (*mvg_info->primitive_info != (PrimitiveInfo *) NULL) { register ssize_t i; *mvg_info->extent=(size_t) extent; for (i=mvg_info->offset+1; i < (ssize_t) extent; i++) (*mvg_info->primitive_info)[i].primitive=UndefinedPrimitive; return(MagickTrue); } } /* Reallocation failed, allocate a primitive to facilitate unwinding. */ (void) ThrowMagickException(mvg_info->exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",""); if (*mvg_info->primitive_info != (PrimitiveInfo *) NULL) *mvg_info->primitive_info=(PrimitiveInfo *) RelinquishMagickMemory( *mvg_info->primitive_info); *mvg_info->primitive_info=(PrimitiveInfo *) AcquireCriticalMemory( PrimitiveExtentPad*quantum); (void) memset(*mvg_info->primitive_info,0,PrimitiveExtentPad*quantum); *mvg_info->extent=1; return(MagickFalse); }
0
[ "CWE-416" ]
ImageMagick
ecf7c6b288e11e7e7f75387c5e9e93e423b98397
302,686,450,971,517,220,000,000,000,000,000,000,000
46
...
static void gap_device_name_read_cb(struct gatt_db_attribute *attrib, unsigned int id, uint16_t offset, uint8_t opcode, struct bt_att *att, void *user_data) { struct btd_gatt_database *database = user_data; uint8_t error = 0; size_t len = 0; const uint8_t *value = NULL; const char *device_name; DBG("GAP Device Name read request\n"); device_name = btd_adapter_get_name(database->adapter); len = strlen(device_name); if (offset > len) { error = BT_ATT_ERROR_INVALID_OFFSET; goto done; } len -= offset; value = len ? (const uint8_t *) &device_name[offset] : NULL; done: gatt_db_attribute_read_result(attrib, id, error, value, len); }
0
[ "CWE-416" ]
bluez
838c0dc7641e1c991c0f3027bf94bee4606012f8
337,104,940,592,849,340,000,000,000,000,000,000,000
27
gatt: Fix not cleaning up when disconnected There is a current use after free possible on a gatt server if a client disconnects while a WriteValue call is being processed with dbus. This patch includes the addition of a pending disconnect callback to handle cleanup better if a disconnect occurs during a write, an acquire write or read operation using bt_att_register_disconnect with the cb.
static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val) { AHCIPortRegs *pr = &s->dev[port].port_regs; DPRINTF(port, "offset: 0x%x val: 0x%x\n", offset, val); switch (offset) { case PORT_LST_ADDR: pr->lst_addr = val; break; case PORT_LST_ADDR_HI: pr->lst_addr_hi = val; break; case PORT_FIS_ADDR: pr->fis_addr = val; break; case PORT_FIS_ADDR_HI: pr->fis_addr_hi = val; break; case PORT_IRQ_STAT: pr->irq_stat &= ~val; ahci_check_irq(s); break; case PORT_IRQ_MASK: pr->irq_mask = val & 0xfdc000ff; ahci_check_irq(s); break; case PORT_CMD: /* Block any Read-only fields from being set; * including LIST_ON and FIS_ON. * The spec requires to set ICC bits to zero after the ICC change * is done. We don't support ICC state changes, therefore always * force the ICC bits to zero. */ pr->cmd = (pr->cmd & PORT_CMD_RO_MASK) | (val & ~(PORT_CMD_RO_MASK|PORT_CMD_ICC_MASK)); /* Check FIS RX and CLB engines */ ahci_cond_start_engines(&s->dev[port]); /* XXX usually the FIS would be pending on the bus here and issuing deferred until the OS enables FIS receival. Instead, we only submit it once - which works in most cases, but is a hack. */ if ((pr->cmd & PORT_CMD_FIS_ON) && !s->dev[port].init_d2h_sent) { ahci_init_d2h(&s->dev[port]); } check_cmd(s, port); break; case PORT_TFDATA: /* Read Only. */ break; case PORT_SIG: /* Read Only */ break; case PORT_SCR_STAT: /* Read Only */ break; case PORT_SCR_CTL: if (((pr->scr_ctl & AHCI_SCR_SCTL_DET) == 1) && ((val & AHCI_SCR_SCTL_DET) == 0)) { ahci_reset_port(s, port); } pr->scr_ctl = val; break; case PORT_SCR_ERR: pr->scr_err &= ~val; break; case PORT_SCR_ACT: /* RW1 */ pr->scr_act |= val; break; case PORT_CMD_ISSUE: pr->cmd_issue |= val; check_cmd(s, port); break; default: break; } }
0
[ "CWE-772", "CWE-401" ]
qemu
d68f0f778e7f4fbd674627274267f269e40f0b04
210,968,862,048,578,560,000,000,000,000,000,000,000
81
ide: ahci: call cleanup function in ahci unit This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
static struct inode *find_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino) { struct inode *inode = NULL; repeat: hlist_for_each_entry(inode, head, i_hash) { if (inode->i_ino != ino) continue; if (inode->i_sb != sb) continue; spin_lock(&inode->i_lock); if (inode->i_state & (I_FREEING|I_WILL_FREE)) { __wait_on_freeing_inode(inode); goto repeat; } if (unlikely(inode->i_state & I_CREATING)) { spin_unlock(&inode->i_lock); return ERR_PTR(-ESTALE); } __iget(inode); spin_unlock(&inode->i_lock); return inode; } return NULL; }
0
[ "CWE-416" ]
tip
8019ad13ef7f64be44d4f892af9c840179009254
93,699,168,238,642,140,000,000,000,000,000,000,000
26
futex: Fix inode life-time issue As reported by Jann, ihold() does not in fact guarantee inode persistence. And instead of making it so, replace the usage of inode pointers with a per boot, machine wide, unique inode identifier. This sequence number is global, but shared (file backed) futexes are rare enough that this should not become a performance issue. Reported-by: Jann Horn <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
static void enable_server_precedence(gnutls_priority_t c) { c->server_precedence = 1; }
0
[ "CWE-310" ]
gnutls
21f89efad7014a5ee0debd4cd3d59e27774b29e6
69,365,389,798,342,660,000,000,000,000,000,000,000
4
handshake: add FALLBACK_SCSV priority option This allows clients to enable the TLS_FALLBACK_SCSV mechanism during the handshake, as defined in RFC7507.
static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len, gsize *ret, GError **gerr) { GIOSSLChannel *chan = (GIOSSLChannel *)handle; gint ret1, err; const char *errstr; ret1 = SSL_write(chan->ssl, (const char *)buf, len); if(ret1 <= 0) { *ret = 0; err = SSL_get_error(chan->ssl, ret1); if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) return G_IO_STATUS_AGAIN; else if(err == SSL_ERROR_ZERO_RETURN) errstr = "server closed connection"; else if (err == SSL_ERROR_SYSCALL) { errstr = ERR_reason_error_string(ERR_get_error()); if (errstr == NULL && ret1 == -1) errstr = strerror(errno); if (errstr == NULL) errstr = "server closed connection unexpectedly"; } else { errstr = ERR_reason_error_string(ERR_get_error()); if (errstr == NULL) errstr = "unknown SSL error"; } g_warning("SSL write error: %s", errstr); *gerr = g_error_new_literal(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, errstr); return G_IO_STATUS_ERROR; } else { *ret = ret1; return G_IO_STATUS_NORMAL; } /*UNREACH*/ return G_IO_STATUS_ERROR; }
0
[ "CWE-20" ]
irssi-proxy
85bbc05b21678e80423815d2ef1dfe26208491ab
241,769,993,549,192,600,000,000,000,000,000,000,000
42
Check if an SSL certificate matches the hostname of the server we are connecting to git-svn-id: http://svn.irssi.org/repos/irssi/trunk@5104 dbcabf3a-b0e7-0310-adc4-f8d773084564
Buf recvEncryptedStream( StreamId streamId, folly::IOBuf& data, uint64_t offset = 0, bool eof = false) { PacketNum packetNum = clientNextAppDataPacketNum++; auto packetData = packetToBuf(createStreamPacket( clientConnectionId.value_or(getTestConnectionId()), *server->getConn().serverConnectionId, packetNum, streamId, data, 0 /* cipherOverhead */, 0 /* largestAcked */, folly::none /* longHeaderOverride */, eof, folly::none, offset)); deliverData(packetData->clone()); return packetData; }
0
[ "CWE-617", "CWE-703" ]
mvfst
a67083ff4b8dcbb7ee2839da6338032030d712b0
161,196,557,028,198,180,000,000,000,000,000,000,000
21
Close connection if we derive an extra 1-rtt write cipher Summary: Fixes CVE-2021-24029 Reviewed By: mjoras, lnicco Differential Revision: D26613890 fbshipit-source-id: 19bb2be2c731808144e1a074ece313fba11f1945
struct dentry *d_alloc_parallel(struct dentry *parent, const struct qstr *name, wait_queue_head_t *wq) { unsigned int hash = name->hash; struct hlist_bl_head *b = in_lookup_hash(parent, hash); struct hlist_bl_node *node; struct dentry *new = d_alloc(parent, name); struct dentry *dentry; unsigned seq, r_seq, d_seq; if (unlikely(!new)) return ERR_PTR(-ENOMEM); retry: rcu_read_lock(); seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1; r_seq = read_seqbegin(&rename_lock); dentry = __d_lookup_rcu(parent, name, &d_seq); if (unlikely(dentry)) { if (!lockref_get_not_dead(&dentry->d_lockref)) { rcu_read_unlock(); goto retry; } if (read_seqcount_retry(&dentry->d_seq, d_seq)) { rcu_read_unlock(); dput(dentry); goto retry; } rcu_read_unlock(); dput(new); return dentry; } if (unlikely(read_seqretry(&rename_lock, r_seq))) { rcu_read_unlock(); goto retry; } hlist_bl_lock(b); if (unlikely(parent->d_inode->i_dir_seq != seq)) { hlist_bl_unlock(b); rcu_read_unlock(); goto retry; } /* * No changes for the parent since the beginning of d_lookup(). * Since all removals from the chain happen with hlist_bl_lock(), * any potential in-lookup matches are going to stay here until * we unlock the chain. All fields are stable in everything * we encounter. */ hlist_bl_for_each_entry(dentry, node, b, d_u.d_in_lookup_hash) { if (dentry->d_name.hash != hash) continue; if (dentry->d_parent != parent) continue; if (!d_same_name(dentry, parent, name)) continue; hlist_bl_unlock(b); /* now we can try to grab a reference */ if (!lockref_get_not_dead(&dentry->d_lockref)) { rcu_read_unlock(); goto retry; } rcu_read_unlock(); /* * somebody is likely to be still doing lookup for it; * wait for them to finish */ spin_lock(&dentry->d_lock); d_wait_lookup(dentry); /* * it's not in-lookup anymore; in principle we should repeat * everything from dcache lookup, but it's likely to be what * d_lookup() would've found anyway. If it is, just return it; * otherwise we really have to repeat the whole thing. */ if (unlikely(dentry->d_name.hash != hash)) goto mismatch; if (unlikely(dentry->d_parent != parent)) goto mismatch; if (unlikely(d_unhashed(dentry))) goto mismatch; if (unlikely(!d_same_name(dentry, parent, name))) goto mismatch; /* OK, it *is* a hashed match; return it */ spin_unlock(&dentry->d_lock); dput(new); return dentry; } rcu_read_unlock(); /* we can't take ->d_lock here; it's OK, though. */ new->d_flags |= DCACHE_PAR_LOOKUP; new->d_wait = wq; hlist_bl_add_head_rcu(&new->d_u.d_in_lookup_hash, b); hlist_bl_unlock(b); return new; mismatch: spin_unlock(&dentry->d_lock); dput(dentry); goto retry; }
0
[ "CWE-362", "CWE-399" ]
linux
49d31c2f389acfe83417083e1208422b4091cd9e
178,982,290,877,122,550,000,000,000,000,000,000,000
102
dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <[email protected]>
static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *lc) { struct libmnt_table *tb = NULL; int rc = 0; struct libmnt_fs *fs; assert(upd); assert(upd->fs); DBG(UPDATE, mnt_debug_h(upd, "%s: modify options", upd->filename)); fs = upd->fs; if (upd->userspace_only) rc = utab_lock(upd); else if (lc) rc = mnt_lock_file(lc); if (rc) return rc; tb = __mnt_new_table_from_file(upd->filename, upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB); if (tb) { struct libmnt_fs *cur = mnt_table_find_target(tb, mnt_fs_get_target(fs), MNT_ITER_BACKWARD); if (cur) { if (upd->userspace_only) rc = mnt_fs_set_attributes(cur, mnt_fs_get_attributes(fs)); if (!rc && !upd->userspace_only) rc = mnt_fs_set_vfs_options(cur, mnt_fs_get_vfs_options(fs)); if (!rc && !upd->userspace_only) rc = mnt_fs_set_fs_options(cur, mnt_fs_get_fs_options(fs)); if (!rc) rc = mnt_fs_set_user_options(cur, mnt_fs_get_user_options(fs)); if (!rc) rc = update_table(upd, tb); } } if (upd->userspace_only) utab_unlock(upd); else if (lc) mnt_unlock_file(lc); mnt_free_table(tb); return rc; }
0
[ "CWE-399" ]
util-linux
28594c9d4fc8a4108408c5749b62933b967ba23b
72,447,668,284,953,800,000,000,000,000,000,000,000
49
libmount: block signals when update utab Signed-off-by: Karel Zak <[email protected]>
event_sched_in(struct perf_event *event, struct perf_cpu_context *cpuctx, struct perf_event_context *ctx) { u64 tstamp = perf_event_time(event); int ret = 0; lockdep_assert_held(&ctx->lock); if (event->state <= PERF_EVENT_STATE_OFF) return 0; event->state = PERF_EVENT_STATE_ACTIVE; event->oncpu = smp_processor_id(); /* * Unthrottle events, since we scheduled we might have missed several * ticks already, also for a heavily scheduling task there is little * guarantee it'll get a tick in a timely manner. */ if (unlikely(event->hw.interrupts == MAX_INTERRUPTS)) { perf_log_throttle(event, 1); event->hw.interrupts = 0; } /* * The new state must be visible before we turn it on in the hardware: */ smp_wmb(); perf_pmu_disable(event->pmu); perf_set_shadow_time(event, ctx, tstamp); perf_log_itrace_start(event); if (event->pmu->add(event, PERF_EF_START)) { event->state = PERF_EVENT_STATE_INACTIVE; event->oncpu = -1; ret = -EAGAIN; goto out; } event->tstamp_running += tstamp - event->tstamp_stopped; if (!is_software_event(event)) cpuctx->active_oncpu++; if (!ctx->nr_active++) perf_event_ctx_activate(ctx); if (event->attr.freq && event->attr.sample_freq) ctx->nr_freq++; if (event->attr.exclusive) cpuctx->exclusive = 1; out: perf_pmu_enable(event->pmu); return ret; }
0
[ "CWE-667" ]
linux
79c9ce57eb2d5f1497546a3946b4ae21b6fdc438
128,691,160,702,937,130,000,000,000,000,000,000,000
60
perf/core: Fix perf_event_open() vs. execve() race Jann reported that the ptrace_may_access() check in find_lively_task_by_vpid() is racy against exec(). Specifically: perf_event_open() execve() ptrace_may_access() commit_creds() ... if (get_dumpable() != SUID_DUMP_USER) perf_event_exit_task(); perf_install_in_context() would result in installing a counter across the creds boundary. Fix this by wrapping lots of perf_event_open() in cred_guard_mutex. This should be fine as perf_event_exit_task() is already called with cred_guard_mutex held, so all perf locks already nest inside it. Reported-by: Jann Horn <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
PHP_FUNCTION(log) { double num, base = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|d", &num, &base) == FAILURE) { return; } if (ZEND_NUM_ARGS() == 1) { RETURN_DOUBLE(log(num)); } if (base <= 0.0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0"); RETURN_FALSE; } if (base == 1) { RETURN_DOUBLE(php_get_nan()); } else { RETURN_DOUBLE(log(num) / log(base)); } }
0
[]
php-src
0d822f6df946764f3f0348b82efae2e1eaa83aa0
266,591,247,696,122,760,000,000,000,000,000,000,000
20
Bug #71201 round() segfault on 64-bit builds
redrawcmd_preedit(void) { if ((State & MODE_CMDLINE) && xic != NULL // && im_get_status() doesn't work when using SCIM && !p_imdisable && im_is_preediting()) { int cmdpos = 0; int cmdspos; int old_row; int old_col; colnr_T col; old_row = msg_row; old_col = msg_col; cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; if (has_mbyte) { for (col = 0; col < preedit_start_col && cmdpos < ccline.cmdlen; ++col) { cmdspos += (*mb_ptr2cells)(ccline.cmdbuff + cmdpos); cmdpos += (*mb_ptr2len)(ccline.cmdbuff + cmdpos); } } else { cmdspos += preedit_start_col; cmdpos += preedit_start_col; } msg_row = cmdline_row + (cmdspos / (int)Columns); msg_col = cmdspos % (int)Columns; if (msg_row >= Rows) msg_row = Rows - 1; for (col = 0; cmdpos < ccline.cmdlen; ++col) { int char_len; int char_attr; char_attr = im_get_feedback_attr(col); if (char_attr < 0) break; // end of preedit string if (has_mbyte) char_len = (*mb_ptr2len)(ccline.cmdbuff + cmdpos); else char_len = 1; msg_outtrans_len_attr(ccline.cmdbuff + cmdpos, char_len, char_attr); cmdpos += char_len; } msg_row = old_row; msg_col = old_col; } }
0
[ "CWE-674", "CWE-787" ]
vim
51f0bfb88a3554ca2dde777d78a59880d1ee37a8
245,444,852,302,153,200,000,000,000,000,000,000,000
60
patch 8.2.4975: recursive command line loop may cause a crash Problem: Recursive command line loop may cause a crash. Solution: Limit recursion of getcmdline().
format_time(void) { static char time_buf[TIME_STR_LEN+1]; strftime(time_buf, sizeof time_buf, "%T ", localtime(&time_now.tv_sec)); return time_buf; }
0
[ "CWE-59", "CWE-61" ]
keepalived
04f2d32871bb3b11d7dc024039952f2fe2750306
176,076,528,800,831,600,000,000,000,000,000,000,000
8
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]>
pk_transaction_files_cb (PkBackendJob *job, PkFiles *item, PkTransaction *transaction) { guint i; _cleanup_free_ gchar *package_id = NULL; _cleanup_strv_free_ gchar **files = NULL; g_return_if_fail (PK_IS_TRANSACTION (transaction)); g_return_if_fail (transaction->priv->tid != NULL); /* get data */ g_object_get (item, "package-id", &package_id, "files", &files, NULL); /* ensure the files have the correct prefix */ if (transaction->priv->role == PK_ROLE_ENUM_DOWNLOAD_PACKAGES && transaction->priv->cached_directory != NULL) { for (i = 0; files[i] != NULL; i++) { if (!g_str_has_prefix (files[i], transaction->priv->cached_directory)) { g_warning ("%s does not have the correct prefix (%s)", files[i], transaction->priv->cached_directory); } } } /* add to results */ pk_results_add_files (transaction->priv->results, item); /* emit */ g_debug ("emitting files %s", package_id); g_dbus_connection_emit_signal (transaction->priv->connection, NULL, transaction->priv->tid, PK_DBUS_INTERFACE_TRANSACTION, "Files", g_variant_new ("(s^as)", package_id != NULL ? package_id : "", files), NULL); }
0
[ "CWE-287" ]
PackageKit
f176976e24e8c17b80eff222572275517c16bdad
322,095,512,342,308,900,000,000,000,000,000,000,000
44
Reinstallation and downgrade require authorization Added new policy actions: * org.freedesktop.packagekit.package-reinstall * org.freedesktop.packagekit.package-downgrade The first does not depend or require any other actions to be authorized except for org.freedesktop.packagekit.package-install-untrusted in case of reinstallation of not trusted package. The same applies to second one plus it implies org.freedesktop.packagekit.package-install action (if the user is authorized to downgrade, he's authorized to install as well). Now the authorization can spawn up to 3 asynchronous calls to polkit for single package because each transaction flag (allow-downgrade, allow-reinstall) the client supplies needs to be checked separately.
int set_nonblock(int fd) { int flags; flags = fcntl(fd, F_GETFL, 0); if (!flags) (void)fcntl(fd, F_SETFL, flags | O_NONBLOCK); return fd; }
0
[ "CWE-22" ]
uftpd
455b47d3756aed162d2d0ef7f40b549f3b5b30fe
243,868,009,757,168,000,000,000,000,000,000,000,000
10
FTP/TFTP: Fix directory traversal regression, reported by Aaron Esau Signed-off-by: Joachim Nilsson <[email protected]>
gen_muldiv(codegen_scope *s, uint8_t op, uint16_t dst) { if (no_peephole(s)) { normal: genop_1(s, op, dst); return; } else { struct mrb_insn_data data = mrb_last_insn(s); mrb_int n, n0; if (addr_pc(s, data.addr) == s->lastlabel || !get_int_operand(s, &data, &n)) { /* not integer immediate */ goto normal; } struct mrb_insn_data data0 = mrb_decode_insn(mrb_prev_pc(s, data.addr)); if (!get_int_operand(s, &data0, &n0) || n == 0) { goto normal; } if (op == OP_MUL) { if (mrb_int_mul_overflow(n0, n, &n)) goto normal; } else { /* OP_DIV */ if (n0 == MRB_INT_MIN && n == -1) goto normal; n = n0 / n; } s->pc = addr_pc(s, data0.addr); gen_int(s, dst, n); } }
0
[ "CWE-415", "CWE-122" ]
mruby
38b164ace7d6ae1c367883a3d67d7f559783faad
94,889,342,985,525,020,000,000,000,000,000,000,000
29
codegen.c: fix a bug in `gen_values()`. - Fix limit handling that fails 15 arguments method calls. - Fix too early argument packing in arrays.
static ssize_t wq_numa_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct workqueue_struct *wq = dev_to_wq(dev); struct workqueue_attrs *attrs; int v, ret = -ENOMEM; apply_wqattrs_lock(); attrs = wq_sysfs_prep_attrs(wq); if (!attrs) goto out_unlock; ret = -EINVAL; if (sscanf(buf, "%d", &v) == 1) { attrs->no_numa = !v; ret = apply_workqueue_attrs_locked(wq, attrs); } out_unlock: apply_wqattrs_unlock(); free_workqueue_attrs(attrs); return ret ?: count; }
0
[ "CWE-200" ]
tip
dfb4357da6ddbdf57d583ba64361c9d792b0e0b1
192,910,699,613,119,240,000,000,000,000,000,000,000
24
time: Remove CONFIG_TIMER_STATS Currently CONFIG_TIMER_STATS exposes process information across namespaces: kernel/time/timer_list.c print_timer(): SEQ_printf(m, ", %s/%d", tmp, timer->start_pid); /proc/timer_list: #11: <0000000000000000>, hrtimer_wakeup, S:01, do_nanosleep, cron/2570 Given that the tracer can give the same information, this patch entirely removes CONFIG_TIMER_STATS. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Kees Cook <[email protected]> Acked-by: John Stultz <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: [email protected] Cc: Lai Jiangshan <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Xing Gao <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Jessica Frazelle <[email protected]> Cc: [email protected] Cc: Nicolas Iooss <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Michal Marek <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Andrew Morton <[email protected]> Cc: [email protected] Cc: Arjan van de Ven <[email protected]> Link: http://lkml.kernel.org/r/20170208192659.GA32582@beast Signed-off-by: Thomas Gleixner <[email protected]>
TEST_F(LoaderTest, NegativeShapeDimension) { SavedModelBundle bundle; RunOptions run_options; SessionOptions session_options; const string export_dir = io::JoinPath(testing::TensorFlowSrcRoot(), kTestFuzzGeneratedNegativeShape); Status st = LoadSavedModel(session_options, run_options, export_dir, {kSavedModelTagServe}, &bundle); EXPECT_FALSE(st.ok()); EXPECT_NE( st.error_message().find("initializes from a tensor with -1 elements"), std::string::npos); }
0
[ "CWE-20", "CWE-703" ]
tensorflow
adf095206f25471e864a8e63a0f1caef53a0e3a6
79,295,081,067,551,900,000,000,000,000,000,000,000
14
Validate `NodeDef`s from `FunctionDefLibrary` of a `GraphDef`. We already validated `NodeDef`s from a `GraphDef` but missed validating those from the `FunctionDefLibrary`. Thus, some maliciously crafted models could evade detection and cause denial of service due to a `CHECK`-fail. PiperOrigin-RevId: 332536309 Change-Id: I052efe919ff1fe2f90815e286a1aa4c54c7b94ff
virDomainRedirdevDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, unsigned int flags) { xmlNodePtr cur; virDomainRedirdevDefPtr def; g_autofree char *bus = NULL; g_autofree char *type = NULL; if (VIR_ALLOC(def) < 0) return NULL; if (!(def->source = virDomainChrSourceDefNew(xmlopt))) goto error; bus = virXMLPropString(node, "bus"); if (bus) { if ((def->bus = virDomainRedirdevBusTypeFromString(bus)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown redirdev bus '%s'"), bus); goto error; } } else { def->bus = VIR_DOMAIN_REDIRDEV_BUS_USB; } type = virXMLPropString(node, "type"); if (type) { if ((def->source->type = virDomainChrTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown redirdev character device type '%s'"), type); goto error; } } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing type in redirdev")); goto error; } cur = node->children; /* boot gets parsed in virDomainDeviceInfoParseXML * source gets parsed in virDomainChrSourceDefParseXML */ if (virDomainChrSourceDefParseXML(def->source, cur, flags, NULL, ctxt) < 0) goto error; if (def->source->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) def->source->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) goto error; if (def->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Invalid address for a USB device")); goto error; } return def; error: virDomainRedirdevDefFree(def); return NULL; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
42,442,255,307,602,324,000,000,000,000,000,000,000
68
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
TEST_P(HeaderIntegrationTest, TestTeHeaderSanitized) { initializeFilter(HeaderMode::Append, false); performRequest( Http::TestRequestHeaderMapImpl{ {":method", "GET"}, {":path", "/"}, {":scheme", "http"}, {":authority", "no-headers.com"}, {"x-request-foo", "downstram"}, {"connection", "te, mike, sam, will, close"}, {"te", "gzip"}, {"mike", "foo"}, {"sam", "bar"}, {"will", "baz"}, }, Http::TestRequestHeaderMapImpl{ {":authority", "no-headers.com"}, {":path", "/"}, {":method", "GET"}, {"x-request-foo", "downstram"}, }, Http::TestResponseHeaderMapImpl{ {"server", "envoy"}, {"content-length", "0"}, {":status", "200"}, {"x-return-foo", "upstream"}, }, Http::TestResponseHeaderMapImpl{ {"server", "envoy"}, {"x-return-foo", "upstream"}, {":status", "200"}, {"connection", "close"}, }); }
0
[ "CWE-22" ]
envoy
5333b928d8bcffa26ab19bf018369a835f697585
174,117,766,893,000,500,000,000,000,000,000,000,000
34
Implement handling of escaped slash characters in URL path Fixes: CVE-2021-29492 Signed-off-by: Yan Avlasov <[email protected]>
void ContentLine_Analyzer::DoDeliver(int len, const u_char* data) { seq_delivered_in_lines = seq; while ( len > 0 && ! SkipDeliveries() ) { if ( (CR_LF_as_EOL & CR_as_EOL) && last_char == '\r' && *data == '\n' ) { // CR is already considered as EOL. // Compress CRLF to just one line termination. // // Note, we test this prior to checking for // "plain delivery" because (1) we might have // made the decision to switch to plain delivery // based on a line terminated with '\r' for // which a '\n' then arrived, and (2) we are // careful when executing plain delivery to // clear last_char once we do so. last_char = *data; --len; ++data; ++seq; ++seq_delivered_in_lines; } if ( plain_delivery_length > 0 ) { int deliver_plain = min(plain_delivery_length, (int64_t)len); last_char = 0; // clear last_char plain_delivery_length -= deliver_plain; is_plain = 1; ForwardStream(deliver_plain, data, IsOrig()); is_plain = 0; data += deliver_plain; len -= deliver_plain; if ( len == 0 ) return; } if ( skip_pending > 0 ) SkipBytes(skip_pending); // Note that the skipping must take place *after* // the CR/LF check above, so that the '\n' of the // previous line is skipped first. if ( seq < seq_to_skip ) { // Skip rest of the data and return int64_t skip_len = seq_to_skip - seq; if ( skip_len > len ) skip_len = len; ForwardUndelivered(seq, skip_len, IsOrig()); len -= skip_len; data += skip_len; seq += skip_len; seq_delivered_in_lines += skip_len; } if ( len <= 0 ) break; int n = DoDeliverOnce(len, data); len -= n; data += n; seq += n; } }
0
[ "CWE-787" ]
bro
6c0f101a62489b1c5927b4ed63b0e1d37db40282
59,097,239,296,141,010,000,000,000,000,000,000,000
70
Patch OOB write in content-line analyzer. A combination of packets can trigger an out of bound write of '0' byte in the content-line analyzer. This bug was found by Frank Meier. Addresses BIT-1856.
ast_for_with_item(struct compiling *c, const node *n) { expr_ty context_expr, optional_vars = NULL; REQ(n, with_item); context_expr = ast_for_expr(c, CHILD(n, 0)); if (!context_expr) return NULL; if (NCH(n) == 3) { optional_vars = ast_for_expr(c, CHILD(n, 2)); if (!optional_vars) { return NULL; } if (!set_context(c, optional_vars, Store, n)) { return NULL; } } return withitem(context_expr, optional_vars, c->c_arena); }
0
[ "CWE-125" ]
cpython
a4d78362397fc3bced6ea80fbc7b5f4827aec55e
110,318,338,920,496,130,000,000,000,000,000,000,000
21
bpo-36495: Fix two out-of-bounds array reads (GH-12641) Research and fix by @bradlarsen.
static NETJOIN_REC *netjoin_add(IRC_SERVER_REC *server, const char *nick, GSList *channels) { NETJOIN_REC *rec; NETJOIN_SERVER_REC *srec; g_return_val_if_fail(server != NULL, NULL); g_return_val_if_fail(nick != NULL, NULL); rec = g_new0(NETJOIN_REC, 1); rec->nick = g_strdup(nick); while (channels != NULL) { NETSPLIT_CHAN_REC *channel = channels->data; rec->old_channels = g_slist_append(rec->old_channels, g_strdup(channel->name)); channels = channels->next; } srec = netjoin_find_server(server); if (srec == NULL) { srec = g_new0(NETJOIN_SERVER_REC, 1); srec->server = server; joinservers = g_slist_append(joinservers, srec); } srec->last_netjoin = time(NULL); srec->netjoins = g_slist_append(srec->netjoins, rec); return rec; }
0
[ "CWE-416" ]
irssi
a6cae91cecba2e8cf11ed779c5da5a229472575c
76,743,204,857,834,800,000,000,000,000,000,000,000
30
Merge pull request #812 from ailin-nemui/tape-netsplit revert netsplit print optimisation (cherry picked from commit 7de1378dab8081932d9096e19ae3d0921e560230)
ofputil_encode_table_config(enum ofputil_table_miss miss, enum ofputil_table_eviction eviction, enum ofputil_table_vacancy vacancy, enum ofp_version version) { uint32_t config = 0; /* Search for "OFPTC_* Table Configuration" in the documentation for more * information on the crazy evolution of this field. */ switch (version) { case OFP10_VERSION: /* OpenFlow 1.0 didn't have such a field, any value ought to do. */ return htonl(0); case OFP11_VERSION: case OFP12_VERSION: /* OpenFlow 1.1 and 1.2 define only OFPTC11_TABLE_MISS_*. */ switch (miss) { case OFPUTIL_TABLE_MISS_DEFAULT: /* Really this shouldn't be used for encoding (the caller should * provide a specific value) but I can't imagine that defaulting to * the fall-through case here will hurt. */ case OFPUTIL_TABLE_MISS_CONTROLLER: default: return htonl(OFPTC11_TABLE_MISS_CONTROLLER); case OFPUTIL_TABLE_MISS_CONTINUE: return htonl(OFPTC11_TABLE_MISS_CONTINUE); case OFPUTIL_TABLE_MISS_DROP: return htonl(OFPTC11_TABLE_MISS_DROP); } OVS_NOT_REACHED(); case OFP13_VERSION: /* OpenFlow 1.3 removed OFPTC11_TABLE_MISS_* and didn't define any new * flags, so this is correct. */ return htonl(0); case OFP14_VERSION: case OFP15_VERSION: case OFP16_VERSION: /* OpenFlow 1.4 introduced OFPTC14_EVICTION and * OFPTC14_VACANCY_EVENTS. */ if (eviction == OFPUTIL_TABLE_EVICTION_ON) { config |= OFPTC14_EVICTION; } if (vacancy == OFPUTIL_TABLE_VACANCY_ON) { config |= OFPTC14_VACANCY_EVENTS; } return htonl(config); } OVS_NOT_REACHED(); }
0
[ "CWE-772" ]
ovs
77ad4225d125030420d897c873e4734ac708c66b
311,694,692,303,058,900,000,000,000,000,000,000,000
52
ofp-util: Fix memory leaks on error cases in ofputil_decode_group_mod(). Found by libFuzzer. Reported-by: Bhargava Shastry <[email protected]> Signed-off-by: Ben Pfaff <[email protected]> Acked-by: Justin Pettit <[email protected]>
int amqp_get_sockfd(amqp_connection_state_t state) { return state->socket ? amqp_socket_get_sockfd(state->socket) : -1; }
0
[ "CWE-20", "CWE-190", "CWE-787" ]
rabbitmq-c
fc85be7123050b91b054e45b91c78d3241a5047a
109,626,118,367,520,200,000,000,000,000,000,000,000
3
lib: check frame_size is >= INT32_MAX When parsing a frame header, validate that the frame_size is less than or equal to INT32_MAX. Given frame_max is limited between 0 and INT32_MAX in amqp_login and friends, this does not change the API. This prevents a potential buffer overflow when a malicious client sends a frame_size that is close to UINT32_MAX, in which causes an overflow when computing state->target_size resulting in a small value there. A buffer is then allocated with the small amount, then memcopy copies the frame_size writing to memory beyond the end of the buffer.
invoke_NPN_HasMethod(PluginInstance *plugin, NPObject *npobj, NPIdentifier methodName) { npw_return_val_if_fail(rpc_method_invoke_possible(g_rpc_connection), false); int error = rpc_method_invoke(g_rpc_connection, RPC_METHOD_NPN_HAS_METHOD, RPC_TYPE_NPW_PLUGIN_INSTANCE, plugin, RPC_TYPE_NP_OBJECT, npobj, RPC_TYPE_NP_IDENTIFIER, &methodName, RPC_TYPE_INVALID); if (error != RPC_ERROR_NO_ERROR) { npw_perror("NPN_HasMethod() invoke", error); return false; } uint32_t ret; error = rpc_method_wait_for_reply(g_rpc_connection, RPC_TYPE_UINT32, &ret, RPC_TYPE_INVALID); if (error != RPC_ERROR_NO_ERROR) { npw_perror("NPN_HasMethod() wait for reply", error); return false; } return ret; }
0
[ "CWE-264" ]
nspluginwrapper
7e4ab8e1189846041f955e6c83f72bc1624e7a98
329,777,425,152,458,820,000,000,000,000,000,000,000
28
Support all the new variables added
get_n_bytes_readable_on_socket(evutil_socket_t fd) { #if defined(FIONREAD) && defined(WIN32) unsigned long lng = EVBUFFER_MAX_READ; if (ioctlsocket(fd, FIONREAD, &lng) < 0) return -1; return (int)lng; #elif defined(FIONREAD) int n = EVBUFFER_MAX_READ; if (ioctl(fd, FIONREAD, &n) < 0) return -1; return n; #else return EVBUFFER_MAX_READ; #endif }
1
[ "CWE-189" ]
libevent
20d6d4458bee5d88bda1511c225c25b2d3198d6c
52,901,552,374,686,530,000,000,000,000,000,000,000
16
Fix CVE-2014-6272 in Libevent 2.0 For this fix, we need to make sure that passing too-large inputs to the evbuffer functions can't make us do bad things with the heap. Also, lower the maximum chunk size to the lower of off_t, size_t maximum. This is necessary since otherwise we could get into an infinite loop if we make a chunk that 'misalign' cannot index into.
int TfLiteIntArrayGetSizeInBytes(int size) { static TfLiteIntArray dummy; return sizeof(dummy) + sizeof(dummy.data[0]) * size; }
0
[ "CWE-190" ]
tensorflow
7c8cc4ec69cd348e44ad6a2699057ca88faad3e5
318,392,206,259,349,770,000,000,000,000,000,000,000
4
Fix a dangerous integer overflow and a malloc of negative size. PiperOrigin-RevId: 371254154 Change-Id: I250a98a3df26328770167025670235a963a72da0
static int pcpu_size_to_slot(int size) { if (size == pcpu_unit_size) return pcpu_nr_slots - 1; return __pcpu_size_to_slot(size); }
0
[]
linux
4f996e234dad488e5d9ba0858bc1bae12eff82c3
182,704,278,227,344,500,000,000,000,000,000,000,000
6
percpu: fix synchronization between chunk->map_extend_work and chunk destruction Atomic allocations can trigger async map extensions which is serviced by chunk->map_extend_work. pcpu_balance_work which is responsible for destroying idle chunks wasn't synchronizing properly against chunk->map_extend_work and may end up freeing the chunk while the work item is still in flight. This patch fixes the bug by rolling async map extension operations into pcpu_balance_work. Signed-off-by: Tejun Heo <[email protected]> Reported-and-tested-by: Alexei Starovoitov <[email protected]> Reported-by: Vlastimil Babka <[email protected]> Reported-by: Sasha Levin <[email protected]> Cc: [email protected] # v3.18+ Fixes: 9c824b6a172c ("percpu: make sure chunk->map array has available space")
int get_part_iter_for_interval_cols_via_map(partition_info *part_info, bool is_subpart, uint32 *store_length_array, uchar *min_value, uchar *max_value, uint min_len, uint max_len, uint flags, PARTITION_ITERATOR *part_iter) { uint32 nparts; get_col_endpoint_func UNINIT_VAR(get_col_endpoint); DBUG_ENTER("get_part_iter_for_interval_cols_via_map"); if (part_info->part_type == RANGE_PARTITION) { get_col_endpoint= get_partition_id_cols_range_for_endpoint; part_iter->get_next= get_next_partition_id_range; } else if (part_info->part_type == LIST_PARTITION) { get_col_endpoint= get_partition_id_cols_list_for_endpoint; part_iter->get_next= get_next_partition_id_list; part_iter->part_info= part_info; DBUG_ASSERT(part_info->num_list_values); } else assert(0); if (flags & NO_MIN_RANGE) part_iter->part_nums.start= part_iter->part_nums.cur= 0; else { // Copy from min_value to record nparts= store_tuple_to_record(part_info->part_field_array, store_length_array, min_value, min_value + min_len); part_iter->part_nums.start= part_iter->part_nums.cur= get_col_endpoint(part_info, TRUE, !(flags & NEAR_MIN), nparts); } if (flags & NO_MAX_RANGE) { if (part_info->part_type == RANGE_PARTITION) part_iter->part_nums.end= part_info->num_parts; else /* LIST_PARTITION */ { DBUG_ASSERT(part_info->part_type == LIST_PARTITION); part_iter->part_nums.end= part_info->num_list_values; } } else { // Copy from max_value to record nparts= store_tuple_to_record(part_info->part_field_array, store_length_array, max_value, max_value + max_len); part_iter->part_nums.end= get_col_endpoint(part_info, FALSE, !(flags & NEAR_MAX), nparts); } if (part_iter->part_nums.start == part_iter->part_nums.end) DBUG_RETURN(0); DBUG_RETURN(1); }
0
[]
server
f305a7ce4bccbd56520d874e1d81a4f29bc17a96
93,070,639,944,308,580,000,000,000,000,000,000,000
65
bugfix: long partition names
MagickExport void DestroyXResources(void) { register int i; unsigned int number_windows; XWindowInfo *magick_windows[MaxXWindows]; XWindows *windows; DestroyXWidget(); windows=XSetWindows((XWindows *) ~0); if ((windows == (XWindows *) NULL) || (windows->display == (Display *) NULL)) return; number_windows=0; magick_windows[number_windows++]=(&windows->context); magick_windows[number_windows++]=(&windows->group_leader); magick_windows[number_windows++]=(&windows->backdrop); magick_windows[number_windows++]=(&windows->icon); magick_windows[number_windows++]=(&windows->image); magick_windows[number_windows++]=(&windows->info); magick_windows[number_windows++]=(&windows->magnify); magick_windows[number_windows++]=(&windows->pan); magick_windows[number_windows++]=(&windows->command); magick_windows[number_windows++]=(&windows->widget); magick_windows[number_windows++]=(&windows->popup); for (i=0; i < (int) number_windows; i++) { if (magick_windows[i]->mapped != MagickFalse) { (void) XWithdrawWindow(windows->display,magick_windows[i]->id, magick_windows[i]->screen); magick_windows[i]->mapped=MagickFalse; } if (magick_windows[i]->name != (char *) NULL) magick_windows[i]->name=(char *) RelinquishMagickMemory(magick_windows[i]->name); if (magick_windows[i]->icon_name != (char *) NULL) magick_windows[i]->icon_name=(char *) RelinquishMagickMemory(magick_windows[i]->icon_name); if (magick_windows[i]->cursor != (Cursor) NULL) { (void) XFreeCursor(windows->display,magick_windows[i]->cursor); magick_windows[i]->cursor=(Cursor) NULL; } if (magick_windows[i]->busy_cursor != (Cursor) NULL) { (void) XFreeCursor(windows->display,magick_windows[i]->busy_cursor); magick_windows[i]->busy_cursor=(Cursor) NULL; } if (magick_windows[i]->highlight_stipple != (Pixmap) NULL) { (void) XFreePixmap(windows->display, magick_windows[i]->highlight_stipple); magick_windows[i]->highlight_stipple=(Pixmap) NULL; } if (magick_windows[i]->shadow_stipple != (Pixmap) NULL) { (void) XFreePixmap(windows->display,magick_windows[i]->shadow_stipple); magick_windows[i]->shadow_stipple=(Pixmap) NULL; } if (magick_windows[i]->matte_image != (XImage *) NULL) { XDestroyImage(magick_windows[i]->matte_image); magick_windows[i]->matte_image=(XImage *) NULL; } if (magick_windows[i]->ximage != (XImage *) NULL) { XDestroyImage(magick_windows[i]->ximage); magick_windows[i]->ximage=(XImage *) NULL; } if (magick_windows[i]->pixmap != (Pixmap) NULL) { (void) XFreePixmap(windows->display,magick_windows[i]->pixmap); magick_windows[i]->pixmap=(Pixmap) NULL; } if (magick_windows[i]->id != (Window) NULL) { (void) XDestroyWindow(windows->display,magick_windows[i]->id); magick_windows[i]->id=(Window) NULL; } if (magick_windows[i]->destroy != MagickFalse) { if (magick_windows[i]->image != (Image *) NULL) { magick_windows[i]->image=DestroyImage(magick_windows[i]->image); magick_windows[i]->image=NewImageList(); } if (magick_windows[i]->matte_pixmap != (Pixmap) NULL) { (void) XFreePixmap(windows->display, magick_windows[i]->matte_pixmap); magick_windows[i]->matte_pixmap=(Pixmap) NULL; } } if (magick_windows[i]->segment_info != (void *) NULL) { #if defined(MAGICKCORE_HAVE_SHARED_MEMORY) XShmSegmentInfo *segment_info; segment_info=(XShmSegmentInfo *) magick_windows[i]->segment_info; if (segment_info != (XShmSegmentInfo *) NULL) if (segment_info[0].shmid >= 0) { if (segment_info[0].shmaddr != NULL) (void) shmdt(segment_info[0].shmaddr); (void) shmctl(segment_info[0].shmid,IPC_RMID,0); segment_info[0].shmaddr=NULL; segment_info[0].shmid=(-1); } #endif magick_windows[i]->segment_info=(void *) RelinquishMagickMemory( magick_windows[i]->segment_info); } } windows->icon_resources=(XResourceInfo *) RelinquishMagickMemory(windows->icon_resources); if (windows->icon_pixel != (XPixelInfo *) NULL) { if (windows->icon_pixel->pixels != (unsigned long *) NULL) windows->icon_pixel->pixels=(unsigned long *) RelinquishMagickMemory(windows->icon_pixel->pixels); if (windows->icon_pixel->annotate_context != (GC) NULL) XFreeGC(windows->display,windows->icon_pixel->annotate_context); windows->icon_pixel=(XPixelInfo *) RelinquishMagickMemory(windows->icon_pixel); } if (windows->pixel_info != (XPixelInfo *) NULL) { if (windows->pixel_info->pixels != (unsigned long *) NULL) windows->pixel_info->pixels=(unsigned long *) RelinquishMagickMemory(windows->pixel_info->pixels); if (windows->pixel_info->annotate_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->annotate_context); if (windows->pixel_info->widget_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->widget_context); if (windows->pixel_info->highlight_context != (GC) NULL) XFreeGC(windows->display,windows->pixel_info->highlight_context); windows->pixel_info=(XPixelInfo *) RelinquishMagickMemory(windows->pixel_info); } if (windows->font_info != (XFontStruct *) NULL) { XFreeFont(windows->display,windows->font_info); windows->font_info=(XFontStruct *) NULL; } if (windows->class_hints != (XClassHint *) NULL) { if (windows->class_hints->res_name != (char *) NULL) windows->class_hints->res_name=DestroyString( windows->class_hints->res_name); if (windows->class_hints->res_class != (char *) NULL) windows->class_hints->res_class=DestroyString( windows->class_hints->res_class); XFree(windows->class_hints); windows->class_hints=(XClassHint *) NULL; } if (windows->manager_hints != (XWMHints *) NULL) { XFree(windows->manager_hints); windows->manager_hints=(XWMHints *) NULL; } if (windows->map_info != (XStandardColormap *) NULL) { XFree(windows->map_info); windows->map_info=(XStandardColormap *) NULL; } if (windows->icon_map != (XStandardColormap *) NULL) { XFree(windows->icon_map); windows->icon_map=(XStandardColormap *) NULL; } if (windows->visual_info != (XVisualInfo *) NULL) { XFree(windows->visual_info); windows->visual_info=(XVisualInfo *) NULL; } if (windows->icon_visual != (XVisualInfo *) NULL) { XFree(windows->icon_visual); windows->icon_visual=(XVisualInfo *) NULL; } (void) XSetWindows((XWindows *) NULL); }
0
[ "CWE-401" ]
ImageMagick6
13801f5d0bd7a6fdb119682d34946636afdb2629
204,204,063,678,795,100,000,000,000,000,000,000,000
189
https://github.com/ImageMagick/ImageMagick/issues/1531
bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CIRCNetwork* pNetwork, CString& sRetMsg) { // Make a copy incase the reference passed in is from CModule::GetModName() CString sMod = sModule; CModule* pModule = FindModule(sMod); if (!pModule) { sRetMsg = t_f("Module [{1}] not loaded.")(sMod); return false; } CModInfo::EModuleType eType = pModule->GetType(); pModule = nullptr; sRetMsg = ""; if (!UnloadModule(sMod, sRetMsg)) { return false; } if (!LoadModule(sMod, sArgs, eType, pUser, pNetwork, sRetMsg)) { return false; } sRetMsg = t_f("Reloaded module {1}.")(sMod); return true; }
0
[ "CWE-20", "CWE-264" ]
znc
8de9e376ce531fe7f3c8b0aa4876d15b479b7311
303,162,309,859,017,500,000,000,000,000,000,000,000
28
Fix remote code execution and privilege escalation vulnerability. To trigger this, need to have a user already. Thanks for Jeriko One <[email protected]> for finding and reporting this. CVE-2019-12816
void* Type_ParametricCurve_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n) { return (void*) cmsDupToneCurve((cmsToneCurve*) Ptr); cmsUNUSED_PARAMETER(n); cmsUNUSED_PARAMETER(self); }
0
[]
Little-CMS
41d222df1bc6188131a8f46c32eab0a4d4cdf1b6
84,622,562,949,730,690,000,000,000,000,000,000,000
7
Memory squeezing fix: lcms2 cmsPipeline construction When creating a new pipeline, lcms would often try to allocate a stage and pass it to cmsPipelineInsertStage without checking whether the allocation succeeded. cmsPipelineInsertStage would then assert (or crash) if it had not. The fix here is to change cmsPipelineInsertStage to check and return an error value. All calling code is then checked to test this return value and cope.
do_leave (VerifyContext *ctx, int delta) { int target = ((gint32)ctx->ip_offset) + delta; if (target >= ctx->code_size || target < 0) ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Branch target out of code at 0x%04x", ctx->ip_offset)); if (!is_correct_leave (ctx->header, ctx->ip_offset, target)) CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Leave not allowed in finally block at 0x%04x", ctx->ip_offset)); ctx->eval.size = 0; ctx->target = target; }
0
[ "CWE-20" ]
mono
4905ef1130feb26c3150b28b97e4a96752e0d399
180,330,225,961,576,100,000,000,000,000,000,000,000
11
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
*/ GF_Err gf_isom_get_pssh(GF_ISOFile *file, u32 pssh_index, u8 **pssh_data, u32 *pssh_size) { GF_Err e; u32 i=0; GF_BitStream *bs; u32 count=1; GF_Box *pssh; while ((pssh = (GF_Box *)gf_list_enum(file->moov->child_boxes, &i))) { if (pssh->type != GF_ISOM_BOX_TYPE_PSSH) continue; if (count == pssh_index) break; count++; } if (!pssh) return GF_BAD_PARAM; bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); e = gf_isom_box_write(pssh, bs); if (!e) { gf_bs_get_content(bs, pssh_data, pssh_size); } gf_bs_del(bs); return e;
0
[ "CWE-476" ]
gpac
ebfa346eff05049718f7b80041093b4c5581c24e
64,240,267,662,658,990,000,000,000,000,000,000,000
21
fixed #1706
i_register_root(gs_memory_t * mem, gs_gc_root_t * rp, gs_ptr_type_t ptype, void **up, client_name_t cname) { gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem; if (rp == NULL) { rp = gs_raw_alloc_struct_immovable(imem->non_gc_memory, &st_gc_root_t, "i_register_root"); if (rp == 0) return_error(gs_error_VMerror); rp->free_on_unregister = true; } else rp->free_on_unregister = false; if_debug3m('8', mem, "[8]register root(%s) 0x%lx -> 0x%lx\n", client_name_string(cname), (ulong)rp, (ulong)up); rp->ptype = ptype; rp->p = up; rp->next = imem->roots; imem->roots = rp; return 0; }
0
[ "CWE-190" ]
ghostpdl
cfde94be1d4286bc47633c6e6eaf4e659bd78066
235,311,004,221,544,520,000,000,000,000,000,000,000
21
Bug 697985: bounds check the array allocations methods The clump allocator has four allocation functions that use 'number of elements' and 'size of elements' parameters (rather than a simple 'number of bytes'). Those need specific bounds checking.
static int tracing_wait_pipe(struct file *filp) { struct trace_iterator *iter = filp->private_data; int ret; while (trace_empty(iter)) { if ((filp->f_flags & O_NONBLOCK)) { return -EAGAIN; } /* * We block until we read something and tracing is disabled. * We still block if tracing is disabled, but we have never * read anything. This allows a user to cat this file, and * then enable tracing. But after we have read something, * we give an EOF when tracing is again disabled. * * iter->pos will be 0 if we haven't read anything. */ if (!tracer_tracing_is_on(iter->tr) && iter->pos) break; mutex_unlock(&iter->mutex); ret = wait_on_pipe(iter, 0); mutex_lock(&iter->mutex); if (ret) return ret; } return 1; }
0
[ "CWE-416" ]
linux
15fab63e1e57be9fdb5eec1bbc5916e9825e9acb
231,773,258,637,837,440,000,000,000,000,000,000,000
35
fs: prevent page refcount overflow in pipe_buf_get Change pipe_buf_get() to return a bool indicating whether it succeeded in raising the refcount of the page (if the thing in the pipe is a page). This removes another mechanism for overflowing the page refcount. All callers converted to handle a failure. Reported-by: Jann Horn <[email protected]> Signed-off-by: Matthew Wilcox <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
static int gtco_input_open(struct input_dev *inputdev) { struct gtco *device = input_get_drvdata(inputdev); device->urbinfo->dev = device->usbdev; if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) return -EIO; return 0; }
0
[ "CWE-703" ]
linux
162f98dea487206d9ab79fc12ed64700667a894d
171,345,434,665,719,450,000,000,000,000,000,000,000
10
Input: gtco - fix crash on detecting device without endpoints The gtco driver expects at least one valid endpoint. If given malicious descriptors that specify 0 for the number of endpoints, it will crash in the probe function. Ensure there is at least one endpoint on the interface before using it. Also let's fix a minor coding style issue. The full correct report of this issue can be found in the public Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1283385 Reported-by: Ralf Spenneberg <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
static void dviprint(DviContext *dvi, const char *command, int sub, const char *fmt, ...) { int i; va_list ap; printf("%s: ", dvi->filename); for(i = 0; i < dvi->depth; i++) printf(" "); printf("%4lu: %s", dtell(dvi), command); if(sub >= 0) printf("%d", sub); if(*fmt) printf(": "); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); }
0
[ "CWE-20" ]
evince
d4139205b010ed06310d14284e63114e88ec6de2
7,364,860,638,861,987,000,000,000,000,000,000,000
15
backends: Fix several security issues in the dvi-backend. See CVE-2010-2640, CVE-2010-2641, CVE-2010-2642 and CVE-2010-2643.
virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem) { unsigned long long memory = virDomainDefGetMemoryTotal(def); int id = def->nmems; if (mem->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && virDomainDefHasDeviceAddress(def, &mem->info)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain already contains a device with the same " "address")); return -1; } if (VIR_APPEND_ELEMENT_COPY(def->mems, def->nmems, mem) < 0) return -1; virDomainDefSetMemoryTotal(def, memory + mem->size); return id; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
118,276,773,087,171,070,000,000,000,000,000,000,000
21
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
gdk_pixbuf__gif_image_begin_load (GdkPixbufModuleSizeFunc size_func, GdkPixbufModulePreparedFunc prepare_func, GdkPixbufModuleUpdatedFunc update_func, gpointer user_data, GError **error) { GifContext *context; #ifdef IO_GIFDEBUG count = 0; #endif context = new_context (); if (context == NULL) { g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Not enough memory to load GIF file")); return NULL; } context->error = error; context->prepare_func = prepare_func; context->update_func = update_func; context->user_data = user_data; return (gpointer) context; }
0
[]
gdk-pixbuf
f8569bb13e2aa1584dde61ca545144750f7a7c98
187,629,085,131,836,830,000,000,000,000,000,000,000
28
GIF: Don't return a partially initialized pixbuf structure It was found that gdk-pixbuf GIF image loader gdk_pixbuf__gif_image_load() routine did not properly handle certain return values from their subroutines. A remote attacker could provide a specially-crafted GIF image, which once opened in an application, linked against gdk-pixbuf would lead to gdk-pixbuf to return partially initialized pixbuf structure, possibly having huge width and height, leading to that particular application termination due excessive memory use. The CVE identifier of CVE-2011-2485 has been assigned to this issue.
dns_zonemgr_attach(dns_zonemgr_t *source, dns_zonemgr_t **target) { REQUIRE(DNS_ZONEMGR_VALID(source)); REQUIRE(target != NULL && *target == NULL); RWLOCK(&source->rwlock, isc_rwlocktype_write); REQUIRE(source->refs > 0); source->refs++; INSIST(source->refs > 0); RWUNLOCK(&source->rwlock, isc_rwlocktype_write); *target = source; }
0
[ "CWE-327" ]
bind9
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
275,110,464,353,074,440,000,000,000,000,000,000,000
11
Update keyfetch_done compute_tag check If in keyfetch_done the compute_tag fails (because for example the algorithm is not supported), don't crash, but instead ignore the key.
kadm5_setv4key_principal(void *server_handle, krb5_principal principal, krb5_keyblock *keyblock) { krb5_db_entry *kdb; osa_princ_ent_rec adb; krb5_int32 now; kadm5_policy_ent_rec pol; krb5_keysalt keysalt; int i, k, kvno, ret, have_pol = 0; #if 0 int last_pwd; #endif kadm5_server_handle_t handle = server_handle; krb5_key_data tmp_key_data; krb5_keyblock *act_mkey; memset( &tmp_key_data, 0, sizeof(tmp_key_data)); CHECK_HANDLE(server_handle); krb5_clear_error_message(handle->context); if (principal == NULL || keyblock == NULL) return EINVAL; if (hist_princ && /* this will be NULL when initializing the databse */ ((krb5_principal_compare(handle->context, principal, hist_princ)) == TRUE)) return KADM5_PROTECT_PRINCIPAL; if (keyblock->enctype != ENCTYPE_DES_CBC_CRC) return KADM5_SETV4KEY_INVAL_ENCTYPE; if ((ret = kdb_get_entry(handle, principal, &kdb, &adb))) return(ret); for (kvno = 0, i=0; i<kdb->n_key_data; i++) if (kdb->key_data[i].key_data_kvno > kvno) kvno = kdb->key_data[i].key_data_kvno; if (kdb->key_data != NULL) cleanup_key_data(handle->context, kdb->n_key_data, kdb->key_data); kdb->key_data = (krb5_key_data*)krb5_db_alloc(handle->context, NULL, sizeof(krb5_key_data)); if (kdb->key_data == NULL) return ENOMEM; memset(kdb->key_data, 0, sizeof(krb5_key_data)); kdb->n_key_data = 1; keysalt.type = KRB5_KDB_SALTTYPE_V4; /* XXX data.magic? */ keysalt.data.length = 0; keysalt.data.data = NULL; ret = krb5_dbe_find_act_mkey(handle->context, active_mkey_list, NULL, &act_mkey); if (ret) goto done; /* use tmp_key_data as temporary location and reallocate later */ ret = krb5_dbe_encrypt_key_data(handle->context, act_mkey, keyblock, &keysalt, kvno + 1, &tmp_key_data); if (ret) { goto done; } for (k = 0; k < tmp_key_data.key_data_ver; k++) { kdb->key_data->key_data_type[k] = tmp_key_data.key_data_type[k]; kdb->key_data->key_data_length[k] = tmp_key_data.key_data_length[k]; if (tmp_key_data.key_data_contents[k]) { kdb->key_data->key_data_contents[k] = krb5_db_alloc(handle->context, NULL, tmp_key_data.key_data_length[k]); if (kdb->key_data->key_data_contents[k] == NULL) { cleanup_key_data(handle->context, kdb->n_key_data, kdb->key_data); kdb->key_data = NULL; kdb->n_key_data = 0; ret = ENOMEM; goto done; } memcpy (kdb->key_data->key_data_contents[k], tmp_key_data.key_data_contents[k], tmp_key_data.key_data_length[k]); memset (tmp_key_data.key_data_contents[k], 0, tmp_key_data.key_data_length[k]); free (tmp_key_data.key_data_contents[k]); tmp_key_data.key_data_contents[k] = NULL; } } kdb->attributes &= ~KRB5_KDB_REQUIRES_PWCHANGE; ret = krb5_timeofday(handle->context, &now); if (ret) goto done; if ((adb.aux_attributes & KADM5_POLICY)) { if ((ret = kadm5_get_policy(handle->lhandle, adb.policy, &pol)) != KADM5_OK) goto done; have_pol = 1; #if 0 /* * The spec says this check is overridden if the caller has * modify privilege. The admin server therefore makes this * check itself (in chpass_principal_wrapper, misc.c). A * local caller implicitly has all authorization bits. */ if (ret = krb5_dbe_lookup_last_pwd_change(handle->context, kdb, &last_pwd)) goto done; if((now - last_pwd) < pol.pw_min_life && !(kdb->attributes & KRB5_KDB_REQUIRES_PWCHANGE)) { ret = KADM5_PASS_TOOSOON; goto done; } #endif if (pol.pw_max_life) kdb->pw_expiration = now + pol.pw_max_life; else kdb->pw_expiration = 0; } else { kdb->pw_expiration = 0; } ret = krb5_dbe_update_last_pwd_change(handle->context, kdb, now); if (ret) goto done; /* unlock principal on this KDC */ kdb->fail_auth_count = 0; if ((ret = kdb_put_entry(handle, kdb, &adb))) goto done; ret = KADM5_OK; done: for (i = 0; i < tmp_key_data.key_data_ver; i++) { if (tmp_key_data.key_data_contents[i]) { memset (tmp_key_data.key_data_contents[i], 0, tmp_key_data.key_data_length[i]); free (tmp_key_data.key_data_contents[i]); } } kdb_free_entry(handle, kdb, &adb); if (have_pol) kadm5_free_policy_ent(handle->lhandle, &pol); return ret; }
0
[ "CWE-703" ]
krb5
c5be6209311d4a8f10fda37d0d3f876c1b33b77b
225,004,589,167,267,640,000,000,000,000,000,000,000
149
Null pointer deref in kadmind [CVE-2012-1013] The fix for #6626 could cause kadmind to dereference a null pointer if a create-principal request contains no password but does contain the KRB5_KDB_DISALLOW_ALL_TIX flag (e.g. "addprinc -randkey -allow_tix name"). Only clients authorized to create principals can trigger the bug. Fix the bug by testing for a null password in check_1_6_dummy. CVSSv2 vector: AV:N/AC:M/Au:S/C:N/I:N/A:P/E:H/RL:O/RC:C [[email protected]: Minor style change and commit message] ticket: 7152 target_version: 1.10.2 tags: pullup
PHP_FUNCTION(openssl_pkcs7_sign) { zval * zcert, * zprivkey, * zheaders; zval * hval; X509 * cert = NULL; EVP_PKEY * privkey = NULL; zend_long flags = PKCS7_DETACHED; PKCS7 * p7 = NULL; BIO * infile = NULL, * outfile = NULL; STACK_OF(X509) *others = NULL; zend_resource *certresource = NULL, *keyresource = NULL; zend_string * strindex; char * infilename; size_t infilename_len; char * outfilename; size_t outfilename_len; char * extracertsfilename = NULL; size_t extracertsfilename_len; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ppzza!|lp!", &infilename, &infilename_len, &outfilename, &outfilename_len, &zcert, &zprivkey, &zheaders, &flags, &extracertsfilename, &extracertsfilename_len) == FAILURE) { return; } RETVAL_FALSE; if (extracertsfilename) { others = php_openssl_load_all_certs_from_file(extracertsfilename); if (others == NULL) { goto clean_exit; } } privkey = php_openssl_evp_from_zval(zprivkey, 0, "", 0, 0, &keyresource); if (privkey == NULL) { php_error_docref(NULL, E_WARNING, "error getting private key"); goto clean_exit; } cert = php_openssl_x509_from_zval(zcert, 0, &certresource); if (cert == NULL) { php_error_docref(NULL, E_WARNING, "error getting cert"); goto clean_exit; } if (php_openssl_open_base_dir_chk(infilename) || php_openssl_open_base_dir_chk(outfilename)) { goto clean_exit; } infile = BIO_new_file(infilename, PHP_OPENSSL_BIO_MODE_R(flags)); if (infile == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "error opening input file %s!", infilename); goto clean_exit; } outfile = BIO_new_file(outfilename, PHP_OPENSSL_BIO_MODE_W(PKCS7_BINARY)); if (outfile == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "error opening output file %s!", outfilename); goto clean_exit; } p7 = PKCS7_sign(cert, privkey, others, infile, (int)flags); if (p7 == NULL) { php_openssl_store_errors(); php_error_docref(NULL, E_WARNING, "error creating PKCS7 structure!"); goto clean_exit; } (void)BIO_reset(infile); /* tack on extra headers */ if (zheaders) { int ret; ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zheaders), strindex, hval) { convert_to_string_ex(hval); if (strindex) { ret = BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), Z_STRVAL_P(hval)); } else { ret = BIO_printf(outfile, "%s\n", Z_STRVAL_P(hval)); } if (ret < 0) { php_openssl_store_errors(); } } ZEND_HASH_FOREACH_END(); } /* write the signed data */ if (!SMIME_write_PKCS7(outfile, p7, infile, (int)flags)) { php_openssl_store_errors(); goto clean_exit; } RETVAL_TRUE; clean_exit: PKCS7_free(p7); BIO_free(infile); BIO_free(outfile); if (others) { sk_X509_pop_free(others, X509_free); } if (privkey && keyresource == NULL) { EVP_PKEY_free(privkey); } if (cert && certresource == NULL) { X509_free(cert); } }
0
[ "CWE-326" ]
php-src
0216630ea2815a5789a24279a1211ac398d4de79
212,698,264,110,996,840,000,000,000,000,000,000,000
113
Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12 bytes IV)
static int handle_preemption_timer(struct kvm_vcpu *vcpu) { handle_fastpath_preemption_timer(vcpu); return 1; }
0
[ "CWE-787" ]
linux
04c4f2ee3f68c9a4bf1653d15f1a9a435ae33f7a
123,416,470,442,822,400,000,000,000,000,000,000,000
5
KVM: VMX: Don't use vcpu->run->internal.ndata as an array index __vmx_handle_exit() uses vcpu->run->internal.ndata as an index for an array access. Since vcpu->run is (can be) mapped to a user address space with a writer permission, the 'ndata' could be updated by the user process at anytime (the user process can set it to outside the bounds of the array). So, it is not safe that __vmx_handle_exit() uses the 'ndata' that way. Fixes: 1aa561b1a4c0 ("kvm: x86: Add "last CPU" to some KVM_EXIT information") Signed-off-by: Reiji Watanabe <[email protected]> Reviewed-by: Jim Mattson <[email protected]> Message-Id: <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
static char *get_reloc_name(RBinReloc *reloc, ut64 addr) { char *reloc_name = NULL; if (reloc->import && reloc->import->name) { reloc_name = sdb_fmt ("reloc.%s_%d", reloc->import->name, (int)(addr & 0xff)); if (!reloc_name) { return NULL; } r_str_replace_char (reloc_name, '$', '_'); } else if (reloc->symbol && reloc->symbol->name) { reloc_name = sdb_fmt ("reloc.%s_%d", reloc->symbol->name, (int)(addr & 0xff)); if (!reloc_name) { return NULL; } r_str_replace_char (reloc_name, '$', '_'); } else if (reloc->is_ifunc) { // addend is the function pointer for the resolving ifunc reloc_name = sdb_fmt ("reloc.ifunc_%"PFMT64x, reloc->addend); } else { // TODO(eddyb) implement constant relocs. } return reloc_name; }
0
[ "CWE-125" ]
radare2
1f37c04f2a762500222dda2459e6a04646feeedf
121,930,589,473,574,170,000,000,000,000,000,000,000
23
Fix #9904 - crash in r2_hoobr_r_read_le32 (over 9000 entrypoints) and read_le oobread (#9923)
void get_file_timestamp_struct(unsigned int flags, struct tm *rectime, struct file_header *file_hdr) { if (PRINT_TRUE_TIME(flags)) { /* Get local time. This is just to fill fields with a default value. */ get_time(rectime, 0); rectime->tm_mday = file_hdr->sa_day; rectime->tm_mon = file_hdr->sa_month; rectime->tm_year = file_hdr->sa_year; /* * Call mktime() to set DST (Daylight Saving Time) flag. * Has anyone a better way to do it? */ rectime->tm_hour = rectime->tm_min = rectime->tm_sec = 0; mktime(rectime); } else { localtime_r((const time_t *) &file_hdr->sa_ust_time, rectime); } }
0
[ "CWE-125" ]
sysstat
fbc691eaaa10d0bcea6741d5a223dc3906106548
81,410,228,440,687,500,000,000,000,000,000,000,000
21
Fix #196 and #199: Out of bound reads security issues Check args before calling memmove() and memset() in remap_struct() function to avoid out of bound reads which would possibly lead to unknown code execution and/or sadf command crash. Signed-off-by: Sebastien GODARD <[email protected]>
Header headerLink(Header h) { if (h != NULL) h->nrefs++; return h; }
0
[ "CWE-125" ]
rpm
8f4b3c3cab8922a2022b9e47c71f1ecf906077ef
236,391,050,723,906,800,000,000,000,000,000,000,000
6
hdrblobInit() needs bounds checks too Users can pass untrusted data to hdrblobInit() and it must be robust against this.
FileBody::FileBody(const fs::path& path, bool auto_delete) : path_(path), chunk_size_(0), auto_delete_(auto_delete), size_(0) { // Don't need to tell file size. }
0
[ "CWE-22" ]
webcc
55a45fd5039061d5cc62e9f1b9d1f7e97a15143f
108,917,583,205,506,500,000,000,000,000,000,000,000
4
fix static file serving security issue; fix url path encoding issue
WasmResult Context::incrementMetric(uint32_t metric_id, int64_t offset) { auto type = static_cast<MetricType>(metric_id & Wasm::kMetricTypeMask); if (type == MetricType::Counter) { auto it = wasm_->counters_.find(metric_id); if (it != wasm_->counters_.end()) { if (offset > 0) { it->second->add(offset); return WasmResult::Ok; } else { return WasmResult::BadArgument; } return WasmResult::NotFound; } } else if (type == MetricType::Gauge) { auto it = wasm_->gauges_.find(metric_id); if (it != wasm_->gauges_.end()) { if (offset > 0) { it->second->add(offset); return WasmResult::Ok; } else { it->second->sub(-offset); return WasmResult::Ok; } } return WasmResult::NotFound; } return WasmResult::BadArgument; }
0
[ "CWE-476" ]
envoy
8788a3cf255b647fd14e6b5e2585abaaedb28153
263,227,490,665,545,850,000,000,000,000,000,000,000
28
1.4 - Do not call into the VM unless the VM Context has been created. (#24) * Ensure that the in VM Context is created before onDone is called. Signed-off-by: John Plevyak <[email protected]> * Update as per offline discussion. Signed-off-by: John Plevyak <[email protected]> * Set in_vm_context_created_ in onNetworkNewConnection. Signed-off-by: John Plevyak <[email protected]> * Add guards to other network calls. Signed-off-by: John Plevyak <[email protected]> * Fix common/wasm tests. Signed-off-by: John Plevyak <[email protected]> * Patch tests. Signed-off-by: John Plevyak <[email protected]> * Remove unecessary file from cherry-pick. Signed-off-by: John Plevyak <[email protected]>
static pj_status_t add_sdp_attr_rtcp_fb( pj_pool_t *pool, const char *pt, const pjmedia_rtcp_fb_cap *cap, pjmedia_sdp_media *m) { pjmedia_sdp_attr *a; char tmp[128]; pj_str_t val; pj_str_t type_name = {0}; if (cap->type < PJMEDIA_RTCP_FB_OTHER) pj_cstr(&type_name, rtcp_fb_type_name[cap->type].name); else if (cap->type == PJMEDIA_RTCP_FB_OTHER) type_name = cap->type_name; if (type_name.slen == 0) return PJ_EINVAL; /* Generate RTCP FB param */ if (cap->param.slen) { pj_ansi_snprintf(tmp, sizeof(tmp), "%s %.*s %.*s", pt, (int)type_name.slen, type_name.ptr, (int)cap->param.slen, cap->param.ptr); } else { pj_ansi_snprintf(tmp, sizeof(tmp), "%s %.*s", pt, (int)type_name.slen, type_name.ptr); } pj_strset2(&val, tmp); /* Generate and add SDP attribute a=rtcp-fb */ a = pjmedia_sdp_attr_create(pool, "rtcp-fb", &val); m->attr[m->attr_count++] = a; return PJ_SUCCESS; }
0
[ "CWE-125" ]
pjproject
22af44e68a0c7d190ac1e25075e1382f77e9397a
137,452,227,701,684,460,000,000,000,000,000,000,000
35
Merge pull request from GHSA-m66q-q64c-hv36 * Prevent OOB read during RTP/RTCP parsing * Add log * Add more logs
int nfc_llcp_send_snl_sdreq(struct nfc_llcp_local *local, struct hlist_head *tlv_list, size_t tlvs_len) { struct nfc_llcp_sdp_tlv *sdreq; struct hlist_node *n; struct sk_buff *skb; skb = nfc_llcp_allocate_snl(local, tlvs_len); if (IS_ERR(skb)) return PTR_ERR(skb); mutex_lock(&local->sdreq_lock); if (hlist_empty(&local->pending_sdreqs)) mod_timer(&local->sdreq_timer, jiffies + msecs_to_jiffies(3 * local->remote_lto)); hlist_for_each_entry_safe(sdreq, n, tlv_list, node) { pr_debug("tid %d for %s\n", sdreq->tid, sdreq->uri); skb_put_data(skb, sdreq->tlv, sdreq->tlv_len); hlist_del(&sdreq->node); hlist_add_head(&sdreq->node, &local->pending_sdreqs); } mutex_unlock(&local->sdreq_lock); skb_queue_tail(&local->tx_queue, skb); return 0; }
0
[ "CWE-787" ]
linux
fe9c842695e26d8116b61b80bfb905356f07834b
34,520,624,224,288,280,000,000,000,000,000,000,000
33
NFC: llcp: Limit size of SDP URI The tlv_len is u8, so we need to limit the size of the SDP URI. Enforce this both in the NLA policy and in the code that performs the allocation and copy, to avoid writing past the end of the allocated buffer. Fixes: d9b8d8e19b073 ("NFC: llcp: Service Name Lookup netlink interface") Signed-off-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
CompositeDeepScanLine::addSource(DeepScanLineInputPart* part) { _Data->check_valid(part->header()); _Data->_part.push_back(part); }
0
[ "CWE-125" ]
openexr
e79d2296496a50826a15c667bf92bdc5a05518b4
225,567,365,837,657,200,000,000,000,000,000,000,000
5
fix memory leaks and invalid memory accesses Signed-off-by: Peter Hillman <[email protected]>
finalize_common (CommonJob *common) { nautilus_progress_info_finish (common->progress); g_timer_destroy (common->time); eel_remove_weak_pointer (&common->parent_window); if (common->skip_files) { g_hash_table_destroy (common->skip_files); } if (common->skip_readdir_error) { g_hash_table_destroy (common->skip_readdir_error); } g_object_unref (common->progress); g_object_unref (common->cancellable); g_free (common); }
0
[]
nautilus
ca2fd475297946f163c32dcea897f25da892b89d
21,014,237,408,546,938,000,000,000,000,000,000,000
17
Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-file-operations.c: * libnautilus-private/nautilus-file-operations.h: Add nautilus_file_mark_desktop_file_trusted(), this now adds a #! line if there is none as well as makes the file executable. * libnautilus-private/nautilus-mime-actions.c: Use nautilus_file_mark_desktop_file_trusted() instead of just setting the permissions. svn path=/trunk/; revision=15006
ecma_date_date_from_time (ecma_number_t time) /**< time value */ { JERRY_ASSERT (!ecma_number_is_nan (time)); int32_t year = ecma_date_year_from_time (time); int32_t day_within_year = ecma_date_day_from_time (time) - ecma_date_day_from_year (year); JERRY_ASSERT (day_within_year >= 0 && day_within_year < ECMA_DATE_DAYS_IN_LEAP_YEAR); int32_t in_leap_year = ecma_date_in_leap_year (year); int32_t month = 11; for (int i = 1; i < 12; i++) { if (day_within_year < first_day_in_month[in_leap_year][i]) { month = i - 1; break; } } return day_within_year + 1 - first_day_in_month[in_leap_year][month]; } /* ecma_date_date_from_time */
0
[ "CWE-416" ]
jerryscript
3bcd48f72d4af01d1304b754ef19fe1a02c96049
124,600,463,056,735,080,000,000,000,000,000,000,000
24
Improve parse_identifier (#4691) Ascii string length is no longer computed during string allocation. JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz [email protected]
left_adjust_char_head(const UChar* start, const UChar* s) { /* In this encoding mb-trail bytes doesn't mix with single bytes. */ const UChar *p; int len; if (s <= start) return (UChar* )s; p = s; while (!eucjp_islead(*p) && p > start) p--; len = enclen(ONIG_ENCODING_EUC_JP, p); if (p + len > s) return (UChar* )p; p += len; return (UChar* )(p + ((s - p) & ~1)); }
0
[ "CWE-125" ]
oniguruma
65a9b1aa03c9bc2dc01b074295b9603232cb3b78
101,681,450,883,534,530,000,000,000,000,000,000,000
17
onig-5.9.2
bool ModMatchExpression::matchesSingleElement(const BSONElement& e, MatchDetails* details) const { if (!e.isNumber()) return false; return overflow::safeMod(e.numberLong(), static_cast<long long>(_divisor)) == _remainder; }
0
[ "CWE-190" ]
mongo
21d8699ed6c517b45e1613e20231cd8eba894985
214,142,098,964,362,830,000,000,000,000,000,000,000
5
SERVER-43699 $mod should not overflow for large negative values
static inline void write_IRQreg_ivpr(OpenPICState *opp, int n_IRQ, uint32_t val) { uint32_t mask; /* NOTE when implementing newer FSL MPIC models: starting with v4.0, * the polarity bit is read-only on internal interrupts. */ mask = IVPR_MASK_MASK | IVPR_PRIORITY_MASK | IVPR_SENSE_MASK | IVPR_POLARITY_MASK | opp->vector_mask; /* ACTIVITY bit is read-only */ opp->src[n_IRQ].ivpr = (opp->src[n_IRQ].ivpr & IVPR_ACTIVITY_MASK) | (val & mask); /* For FSL internal interrupts, The sense bit is reserved and zero, * and the interrupt is always level-triggered. Timers and IPIs * have no sense or polarity bits, and are edge-triggered. */ switch (opp->src[n_IRQ].type) { case IRQ_TYPE_NORMAL: opp->src[n_IRQ].level = !!(opp->src[n_IRQ].ivpr & IVPR_SENSE_MASK); break; case IRQ_TYPE_FSLINT: opp->src[n_IRQ].ivpr &= ~IVPR_SENSE_MASK; break; case IRQ_TYPE_FSLSPECIAL: opp->src[n_IRQ].ivpr &= ~(IVPR_POLARITY_MASK | IVPR_SENSE_MASK); break; } openpic_update_irq(opp, n_IRQ); DPRINTF("Set IVPR %d to 0x%08x -> 0x%08x\n", n_IRQ, val, opp->src[n_IRQ].ivpr); }
0
[ "CWE-119" ]
qemu
73d963c0a75cb99c6aaa3f6f25e427aa0b35a02e
105,850,682,462,908,080,000,000,000,000,000,000,000
36
openpic: avoid buffer overrun on incoming migration CVE-2013-4534 opp->nb_cpus is read from the wire and used to determine how many IRQDest elements to read into opp->dst[]. If the value exceeds the length of opp->dst[], MAX_CPU, opp->dst[] can be overrun with arbitrary data from the wire. Fix this by failing migration if the value read from the wire exceeds MAX_CPU. Signed-off-by: Michael Roth <[email protected]> Reviewed-by: Alexander Graf <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
starttermcap(void) { if (full_screen && !termcap_active) { MAY_WANT_TO_LOG_THIS; out_str(T_TI); // start termcap mode out_str(T_CTI); // start "raw" mode out_str(T_KS); // start "keypad transmit" mode out_str(T_BE); // enable bracketed paste mode #if defined(UNIX) || defined(VMS) // Enable xterm's focus reporting mode when 'esckeys' is set. if (p_ek && *T_FE != NUL) out_str(T_FE); #endif out_flush(); termcap_active = TRUE; screen_start(); // don't know where cursor is now #ifdef FEAT_TERMRESPONSE # ifdef FEAT_GUI if (!gui.in_use && !gui.starting) # endif { may_req_termresponse(); // Immediately check for a response. If t_Co changes, we don't // want to redraw with wrong colors first. if (crv_status.tr_progress == STATUS_SENT) check_for_codes_from_term(); } #endif } }
0
[ "CWE-125", "CWE-787" ]
vim
e178af5a586ea023622d460779fdcabbbfac0908
60,664,700,138,903,040,000,000,000,000,000,000,000
34
patch 8.2.5160: accessing invalid memory after changing terminal size Problem: Accessing invalid memory after changing terminal size. Solution: Adjust cmdline_row and msg_row to the value of Rows.
static void ff_layout_reset_write(struct nfs_pgio_header *hdr, bool retry_pnfs) { struct rpc_task *task = &hdr->task; pnfs_layoutcommit_inode(hdr->inode, false); if (retry_pnfs) { dprintk("%s Reset task %5u for i/o through pNFS " "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, hdr->task.tk_pid, hdr->inode->i_sb->s_id, (unsigned long long)NFS_FILEID(hdr->inode), hdr->args.count, (unsigned long long)hdr->args.offset); hdr->completion_ops->reschedule_io(hdr); return; } if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { dprintk("%s Reset task %5u for i/o through MDS " "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, hdr->task.tk_pid, hdr->inode->i_sb->s_id, (unsigned long long)NFS_FILEID(hdr->inode), hdr->args.count, (unsigned long long)hdr->args.offset); trace_pnfs_mds_fallback_write_done(hdr->inode, hdr->args.offset, hdr->args.count, IOMODE_RW, NFS_I(hdr->inode)->layout, hdr->lseg); task->tk_status = pnfs_write_done_resend_to_mds(hdr); } }
0
[ "CWE-787" ]
linux
ed34695e15aba74f45247f1ee2cf7e09d449f925
219,722,434,230,882,200,000,000,000,000,000,000,000
35
pNFS/flexfiles: fix incorrect size check in decode_nfs_fh() We (adam zabrocki, alexander matrosov, alexander tereshkin, maksym bazalii) observed the check: if (fh->size > sizeof(struct nfs_fh)) should not use the size of the nfs_fh struct which includes an extra two bytes from the size field. struct nfs_fh { unsigned short size; unsigned char data[NFS_MAXFHSIZE]; } but should determine the size from data[NFS_MAXFHSIZE] so the memcpy will not write 2 bytes beyond destination. The proposed fix is to compare against the NFS_MAXFHSIZE directly, as is done elsewhere in fs code base. Fixes: d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver") Signed-off-by: Nikola Livic <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
void EvaluateXYZ2Lab(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) { cmsCIELab Lab; cmsCIEXYZ XYZ; const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ; // From 0..1.0 to XYZ XYZ.X = In[0] * XYZadj; XYZ.Y = In[1] * XYZadj; XYZ.Z = In[2] * XYZadj; cmsXYZ2Lab(NULL, &Lab, &XYZ); // From V4 Lab to 0..1.0 Out[0] = (cmsFloat32Number) (Lab.L / 100.0); Out[1] = (cmsFloat32Number) ((Lab.a + 128.0) / 255.0); Out[2] = (cmsFloat32Number) ((Lab.b + 128.0) / 255.0); return; cmsUNUSED_PARAMETER(mpe); }
0
[]
Little-CMS
b0d5ffd4ad91cf8683ee106f13742db3dc66599a
39,091,975,532,897,817,000,000,000,000,000,000,000
23
Memory Squeezing: LCMS2: CLUTElemDup Check for allocation failures and tidy up if found.
PHP_FUNCTION(gethostbynamel) { char *hostname; size_t hostname_len; struct hostent *hp; struct in_addr in; int i; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hostname, &hostname_len) == FAILURE) { return; } if(hostname_len > MAXFQDNLEN) { /* name too long, protect from CVE-2015-0235 */ php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN); RETURN_FALSE; } hp = php_network_gethostbyname(hostname); if (hp == NULL || hp->h_addr_list == NULL) { RETURN_FALSE; } array_init(return_value); for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) { in = *(struct in_addr *) hp->h_addr_list[i]; add_next_index_string(return_value, inet_ntoa(in)); } }
0
[ "CWE-125" ]
php-src
8d3dfabef459fe7815e8ea2fd68753fd17859d7b
284,799,578,494,294,060,000,000,000,000,000,000,000
30
Fix #77369 - memcpy with negative length via crafted DNS response
SSLHandshakeServerParseClientHello( AsyncSSLSocket::UniquePtr socket, bool preverifyResult, bool verifyResult) : SSLHandshakeBase(std::move(socket), preverifyResult, verifyResult) { socket_->enableClientHelloParsing(); socket_->sslAccept(this, std::chrono::milliseconds::zero()); }
0
[ "CWE-125" ]
folly
c321eb588909646c15aefde035fd3133ba32cdee
136,152,756,613,194,800,000,000,000,000,000,000,000
8
Handle close_notify as standard writeErr in AsyncSSLSocket. Summary: Fixes CVE-2019-11934 Reviewed By: mingtaoy Differential Revision: D18020613 fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836
static int __set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) { int pending_vec, max_bits; int mmu_reset_needed = 0; int ret = __set_sregs_common(vcpu, sregs, &mmu_reset_needed, true); if (ret) return ret; if (mmu_reset_needed) kvm_mmu_reset_context(vcpu); max_bits = KVM_NR_INTERRUPTS; pending_vec = find_first_bit( (const unsigned long *)sregs->interrupt_bitmap, max_bits); if (pending_vec < max_bits) { kvm_queue_interrupt(vcpu, pending_vec, false); pr_debug("Set back pending irq %d\n", pending_vec); kvm_make_request(KVM_REQ_EVENT, vcpu); } return 0; }
0
[ "CWE-476" ]
linux
55749769fe608fa3f4a075e42e89d237c8e37637
298,814,658,039,656,960,000,000,000,000,000,000,000
23
KVM: x86: Fix wall clock writes in Xen shared_info not to mark page dirty When dirty ring logging is enabled, any dirty logging without an active vCPU context will cause a kernel oops. But we've already declared that the shared_info page doesn't get dirty tracking anyway, since it would be kind of insane to mark it dirty every time we deliver an event channel interrupt. Userspace is supposed to just assume it's always dirty any time a vCPU can run or event channels are routed. So stop using the generic kvm_write_wall_clock() and just write directly through the gfn_to_pfn_cache that we already have set up. We can make kvm_write_wall_clock() static in x86.c again now, but let's not remove the 'sec_hi_ofs' argument even though it's not used yet. At some point we *will* want to use that for KVM guests too. Fixes: 629b5348841a ("KVM: x86/xen: update wallclock region") Reported-by: butt3rflyh4ck <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
static void crypt_reset_null_type(struct crypt_device *cd) { if (cd->type) return; free(cd->u.none.active_name); cd->u.none.active_name = NULL; }
0
[ "CWE-345" ]
cryptsetup
0113ac2d889c5322659ad0596d4cfc6da53e356c
48,651,799,691,174,460,000,000,000,000,000,000,000
8
Fix CVE-2021-4122 - LUKS2 reencryption crash recovery attack Fix possible attacks against data confidentiality through LUKS2 online reencryption extension crash recovery. An attacker can modify on-disk metadata to simulate decryption in progress with crashed (unfinished) reencryption step and persistently decrypt part of the LUKS device. This attack requires repeated physical access to the LUKS device but no knowledge of user passphrases. The decryption step is performed after a valid user activates the device with a correct passphrase and modified metadata. There are no visible warnings for the user that such recovery happened (except using the luksDump command). The attack can also be reversed afterward (simulating crashed encryption from a plaintext) with possible modification of revealed plaintext. The problem was caused by reusing a mechanism designed for actual reencryption operation without reassessing the security impact for new encryption and decryption operations. While the reencryption requires calculating and verifying both key digests, no digest was needed to initiate decryption recovery if the destination is plaintext (no encryption key). Also, some metadata (like encryption cipher) is not protected, and an attacker could change it. Note that LUKS2 protects visible metadata only when a random change occurs. It does not protect against intentional modification but such modification must not cause a violation of data confidentiality. The fix introduces additional digest protection of reencryption metadata. The digest is calculated from known keys and critical reencryption metadata. Now an attacker cannot create correct metadata digest without knowledge of a passphrase for used keyslots. For more details, see LUKS2 On-Disk Format Specification version 1.1.0.
pk_transaction_get_repo_list (PkTransaction *transaction, GVariant *params, GDBusMethodInvocation *context) { PkBitfield filter; _cleanup_error_free_ GError *error = NULL; g_return_if_fail (PK_IS_TRANSACTION (transaction)); g_return_if_fail (transaction->priv->tid != NULL); g_variant_get (params, "(t)", &filter); g_debug ("GetRepoList method called"); /* not implemented yet */ if (!pk_backend_is_implemented (transaction->priv->backend, PK_ROLE_ENUM_GET_REPO_LIST)) { g_set_error (&error, PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_NOT_SUPPORTED, "GetRepoList not supported by backend"); pk_transaction_set_state (transaction, PK_TRANSACTION_STATE_ERROR); goto out; } /* save so we can run later */ transaction->priv->cached_filters = filter; pk_transaction_set_role (transaction, PK_ROLE_ENUM_GET_REPO_LIST); pk_transaction_set_state (transaction, PK_TRANSACTION_STATE_READY); out: pk_transaction_dbus_return (context, error); }
0
[ "CWE-287" ]
PackageKit
f176976e24e8c17b80eff222572275517c16bdad
288,193,525,608,056,730,000,000,000,000,000,000,000
33
Reinstallation and downgrade require authorization Added new policy actions: * org.freedesktop.packagekit.package-reinstall * org.freedesktop.packagekit.package-downgrade The first does not depend or require any other actions to be authorized except for org.freedesktop.packagekit.package-install-untrusted in case of reinstallation of not trusted package. The same applies to second one plus it implies org.freedesktop.packagekit.package-install action (if the user is authorized to downgrade, he's authorized to install as well). Now the authorization can spawn up to 3 asynchronous calls to polkit for single package because each transaction flag (allow-downgrade, allow-reinstall) the client supplies needs to be checked separately.